/* MacMM · Card-Key Portal — shared styles (index.html + admin.html) */

:root {
  --bg: #f1f3f6;
  --card-bg: #ffffff;
  --card-radius: 16px;
  --card-shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 8px 24px rgba(16, 24, 40, 0.06);
  --text: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --input-bg: #ffffff;
  --accent: #2563eb;
  --accent-ink: #1d4ed8;
  --accent-soft: #eff6ff;
  --grad-from: #2563eb;
  --grad-to: #1e40af;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --gap: 16px;

  /* status badge colors */
  --st-received-bg: #e5e7eb; --st-received-fg: #374151;
  --st-processing-bg: #dbeafe; --st-processing-fg: #1e40af;
  --st-done-bg: #dcfce7; --st-done-fg: #166534;
  --st-failed-bg: #fee2e2; --st-failed-fg: #991b1b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f17;
    --card-bg: #151b26;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
    --text: #e5e7eb;
    --text-muted: #9ca3af;
    --border: #2a3342;
    --input-bg: #0f141d;
    --accent: #3b82f6;
    --accent-ink: #60a5fa;
    --accent-soft: #16233b;
    --grad-from: #2563eb;
    --grad-to: #1e3a8a;
    --danger: #f87171;
    --danger-soft: #2a1618;
    --danger-border: #5b2526;
    --success: #4ade80;
    --success-soft: #122017;

    --st-received-bg: #374151; --st-received-fg: #d1d5db;
    --st-processing-bg: #1e3a5f; --st-processing-fg: #93c5fd;
    --st-done-bg: #14532d; --st-done-fg: #86efac;
    --st-failed-bg: #4c1d1d; --st-failed-fg: #fca5a5;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0f17;
  --card-bg: #151b26;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --border: #2a3342;
  --input-bg: #0f141d;
  --accent: #3b82f6;
  --accent-ink: #60a5fa;
  --accent-soft: #16233b;
  --grad-from: #2563eb;
  --grad-to: #1e3a8a;
  --danger: #f87171;
  --danger-soft: #2a1618;
  --danger-border: #5b2526;
  --success: #4ade80;
  --success-soft: #122017;
  --st-received-bg: #374151; --st-received-fg: #d1d5db;
  --st-processing-bg: #1e3a5f; --st-processing-fg: #93c5fd;
  --st-done-bg: #14532d; --st-done-fg: #86efac;
  --st-failed-bg: #4c1d1d; --st-failed-fg: #fca5a5;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- Layout ---------- */
.wrap {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px 56px;
}
.wrap--wide { max-width: 980px; }

.brand {
  text-align: center;
  margin: 8px 0 20px;
}
.brand h1 {
  font-size: 20px;
  margin: 0;
  letter-spacing: -0.01em;
}
.brand p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------- Card ---------- */
.card {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 20px;
  margin-bottom: var(--gap);
  border: 1px solid transparent;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .card { border-color: var(--border); }
}
:root[data-theme="dark"] .card { border-color: var(--border); }

.card h2 {
  font-size: 17px;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h2 .sub { font-size: 12px; font-weight: 400; color: var(--text-muted); margin-left: auto; }

/* ---------- Form fields ---------- */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
label .req { color: var(--danger); }
label .hint { font-weight: 400; color: var(--text-muted); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 11px 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: .8; }

/* password with eye toggle */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  padding: 6px 8px;
  line-height: 1;
  color: var(--text-muted);
  border-radius: 8px;
}
.pw-toggle:hover { color: var(--text); }

/* ---------- Tabs toggle ---------- */
.tabs {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 14px;
}
.tabs button {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}
.tabs button[aria-selected="true"] {
  background: var(--card-bg);
  color: var(--accent-ink);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}

.tabpanel[hidden] { display: none; }
.counter { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.counter.ok { color: var(--success); }

/* ---------- Hint / warning boxes ---------- */
.hint-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  margin: 14px 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--grad-from), var(--grad-to));
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: filter .15s, transform .05s, opacity .15s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; filter: none; }

.btn-secondary {
  background: var(--card-bg);
  color: var(--accent-ink);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn-secondary:hover { background: var(--accent-soft); filter: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  box-shadow: none;
  width: auto;
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 9px;
}
.btn-ghost:hover { background: var(--bg); filter: none; }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger-border);
  box-shadow: none;
  width: auto;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
}
.btn-danger:hover { background: var(--danger-soft); filter: none; }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { width: auto; flex: 1; }

/* ---------- Messages ---------- */
.msg { font-size: 13px; margin-top: 12px; padding: 10px 12px; border-radius: 10px; display: none; }
.msg.show { display: block; }
.msg.error { background: var(--danger-soft); border: 1px solid var(--danger-border); color: var(--danger); }
.msg.success { background: var(--success-soft); border: 1px solid color-mix(in srgb, var(--success) 40%, transparent); color: var(--success); }
.field-error { color: var(--danger); font-size: 12px; margin-top: 5px; display: none; }
.field-error.show { display: block; }
input.invalid, textarea.invalid { border-color: var(--danger); }

/* ---------- Turnstile ---------- */
.turnstile-slot { margin: 14px 0; min-height: 0; }
.turnstile-slot:empty { margin: 0; }

/* ---------- Order status readout ---------- */
.order-view { margin-top: 14px; }
.order-view[hidden] { display: none; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--text-muted); font-weight: 600; }
.kv dd { margin: 0; word-break: break-word; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: capitalize;
  background: var(--st-received-bg);
  color: var(--st-received-fg);
}
.badge.received { background: var(--st-received-bg); color: var(--st-received-fg); }
.badge.processing { background: var(--st-processing-bg); color: var(--st-processing-fg); }
.badge.done { background: var(--st-done-bg); color: var(--st-done-fg); }
.badge.failed { background: var(--st-failed-bg); color: var(--st-failed-fg); }

/* ---------- Admin ---------- */
.login-wrap { max-width: 400px; margin: 10vh auto 0; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.toolbar h1 { font-size: 18px; margin: 0; }
.toolbar .spacer { margin-left: auto; }

.admin-tabs { margin-bottom: 16px; }

.table-wrap { overflow-x: auto; border-radius: 12px; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--card-bg);
}
table.data th, table.data td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: var(--accent-soft); }
table.data td.wrap-cell { white-space: normal; word-break: break-word; }
.muted { color: var(--text-muted); }
.empty-row td { text-align: center; color: var(--text-muted); padding: 24px; }

.codes-out {
  margin-top: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 180px;
  overflow: auto;
}
.codes-out[hidden] { display: none; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .row-2 { grid-template-columns: 1fr; } }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  z-index: 50;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  width: 100%;
  max-width: 560px;
  padding: 20px;
  border: 1px solid var(--border);
}
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .close { margin-left: auto; }
.modal-close {
  border: none; background: transparent; cursor: pointer;
  font-size: 20px; line-height: 1; color: var(--text-muted); padding: 4px 8px;
}
.modal-close:hover { color: var(--text); }

.cred-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0 14px; }
.cred-table th, .cred-table td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all;
}
.cred-table th { font-family: inherit; color: var(--text-muted); font-size: 12px; }

.inline-note { font-size: 12px; color: var(--text-muted); margin: 2px 0 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- Payment page ---------- */
.plans { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.plan {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.plan:hover { border-color: var(--accent); }
.plan.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.plan-info { display: flex; flex-direction: column; gap: 2px; }
.plan-name { font-size: 15px; font-weight: 700; }
.plan-qty { font-size: 12px; color: var(--text-muted); }
.plan-price { margin-left: auto; font-size: 18px; font-weight: 800; color: var(--accent-ink); }

.pay-btns { display: flex; flex-direction: column; gap: 10px; }

.back-link { text-align: center; margin: 4px 0 0; font-size: 13px; }
.back-link a { color: var(--accent-ink); text-decoration: none; }
.back-link a:hover { text-decoration: underline; }

/* QR modal body */
.qr-hint { font-size: 13px; color: var(--text-muted); margin: 0 0 12px; text-align: center; }
.qr-box {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.qr-box img, .qr-box canvas { display: block; }
.qr-box .qr-fallback { color: var(--text-muted); }
.qr-link-wrap { text-align: center; margin: 12px 0 0; }
.qr-link-wrap a { color: var(--accent-ink); text-decoration: none; font-weight: 600; }
.qr-link-wrap a:hover { text-decoration: underline; }
.qr-amount { text-align: center; font-size: 14px; font-weight: 600; margin: 12px 0 4px; }
.qr-status { text-align: center; font-size: 13px; margin: 4px 0 0; }

/* My orders list */
.order-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.order-item:last-child { margin-bottom: 0; }
.order-item-head { display: flex; align-items: center; gap: 10px; }
.order-item-head .badge { margin-left: auto; }
.order-item-meta { font-size: 12px; margin: 6px 0 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; word-break: break-all; }
.codes-out.mini { margin-top: 10px; max-height: 140px; }
