:root {
  --panel: #487FFF;   /* tab background */
  --ink: #161A1E;
  --muted: #6b7280;
  --accent: #ff5a1f;
  --line: #e6e8eb;
  --page: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--page);
}

.card {
  width: 100%;
  max-width: 440px;
  text-align: center;
  padding: 8px;
}

/* --- Logo --- */
.logo {
  margin-bottom: 32px;
  min-height: 44px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.logo img { height: 80px; width: auto; max-width: 300px; }
.logo-fallback {
  display: none;   /* shown only if the logo image is missing */
  font-size: 15px;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--accent);
}

h1 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: -.02em;
}

.sub { margin: 0 0 28px; color: var(--muted); }

/* --- Tabs: each a real folder-tab sitting on the dark panel --- */
.tabset { text-align: center; }

.tabs {
  display: flex;
  gap: 14px;
}

.tab {
  appearance: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: 1;
  padding: 36px 20px;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  background: #EBECF1;                  /* inactive: email tab color */
  border: 2px solid transparent;
  border-radius: 24px;
  transition: transform .1s ease, background .15s ease, color .15s ease;
}

.tab:active { transform: translateY(-1px); }
.tab:focus-visible { outline: 2px solid var(--panel); outline-offset: 3px; }

.tab.active {
  background: var(--panel);            /* selected: brand blue */
  color: #fff;
}

.tab-icon { width: 40px; height: 40px; }

/* --- Claim button --- */
.claim-btn {
  appearance: none;
  width: 100%;
  margin-top: 20px;
  padding: 16px 20px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--panel);
  border: 0;
  border-radius: 60px;
  cursor: pointer;
  transition: filter .15s ease, transform .06s ease, opacity .15s ease;
}
.claim-btn:hover:not(:disabled) { filter: brightness(1.08); }
.claim-btn:active:not(:disabled) { transform: translateY(1px); }
.claim-btn:disabled { opacity: .45; cursor: not-allowed; }

/* --- Redeemed code --- */
.code {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 8px 0 20px;
  padding: 20px;
  font: 700 24px/1 "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: .06em;
  color: var(--ink);
  background: #f6f7f8;
  border: 1px dashed var(--panel);
  border-radius: 12px;
  word-break: break-all;
  cursor: pointer;
  transition: background .15s ease, transform .06s ease;
}
.code:hover { background: #eef0f2; }
.code:active { transform: scale(.99); }
.code:focus-visible { outline: 2px solid var(--panel); outline-offset: 2px; }
.copy-icon { flex: 0 0 auto; color: var(--panel); transition: color .15s ease; }
.code:hover .copy-icon { color: var(--panel); }
.code.copied { background: #e7f6ef; border-color: #22a06b; }
.code.copied .copy-icon { color: #22a06b; }

/* --- iOS redeem button --- */
.redeem-btn {
  display: block;
  width: 100%;
  padding: 16px 20px;
  margin-bottom: 20px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  background: var(--panel);
  border-radius: 60px;
  transition: filter .15s ease, transform .06s ease;
}
.redeem-btn:hover { filter: brightness(1.08); }
.redeem-btn:active { transform: translateY(1px); }

/* --- Android steps --- */
.steps {
  text-align: left;
  margin: 0 0 20px;
  padding-left: 22px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.7;
}
.steps li { margin-bottom: 4px; }

.note { margin: 0; font-size: 13px; color: var(--muted); }
.note.warn { margin-top: 16px; }
.note.error {
  margin-bottom: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  color: #c0392b;
  background: #fdecea;
  border-radius: 10px;
}
.note.success {
  margin-bottom: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  color: #22a06b;
  background: #e7f6ef;
  border-radius: 10px;
}
.note.preview {
  margin-top: 18px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--panel);
  background: #eef2ff;
  border-radius: 10px;
}

/* --- Dashboard form --- */
.dash-form { text-align: left; }
.dash-form label {
  display: block;
  margin: 16px 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.dash-form select,
.dash-form input[type="email"],
.dash-form input[type="text"],
.dash-form input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  color: var(--ink);
  background: #f6f7f8;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.dash-form select:focus,
.dash-form input[type="email"]:focus,
.dash-form input[type="text"]:focus,
.dash-form input[type="password"]:focus { outline: 2px solid var(--panel); outline-offset: 1px; }
.dash-checkbox {
  display: flex !important;
  align-items: center;
  gap: 10px;
  font-weight: 400 !important;
  margin-top: 20px !important;
}
.dash-checkbox input { width: 18px; height: 18px; }

/* --- History button (corner) --- */
.history-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--panel);
  text-decoration: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 30px;
  transition: background .15s ease;
}
.history-btn:hover { background: #f6f7f8; }
.history-btn.corner-left { right: auto; left: 20px; }
.corner-form { display: contents; }
.corner-form .history-btn { appearance: none; font-family: inherit; cursor: pointer; }

.user-menu { position: fixed; top: 20px; right: 20px; }
.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 6px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 30px;
  cursor: pointer;
  transition: background .15s ease;
}
.user-menu-btn:hover { background: #f6f7f8; }
.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--panel);
  color: #fff;
  font-size: 14px;
}
.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
  overflow: hidden;
}
.user-menu.open .user-dropdown { display: block; }
.user-dropdown-item {
  display: block;
  width: 100%;
  padding: 12px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  color: var(--ink);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
}
.user-dropdown-item:hover { background: #f6f7f8; }
.user-dropdown-logout { color: #d33; }

/* --- Modal --- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,.45);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 18px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal h2 { margin: 0 0 20px; font-size: 22px; }
.modal-close {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 32px;
  height: 32px;
  font-size: 24px;
  line-height: 1;
  color: var(--muted, #888);
  background: none;
  border: none;
  cursor: pointer;
}
.modal-close:hover { color: var(--ink); }

/* --- Password show/hide --- */
.pw-field { position: relative; }
.pw-field input { width: 100%; padding-right: 44px; }
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  opacity: .55;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 20px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z'/><circle cx='12' cy='12' r='3'/></svg>");
}
.pw-toggle:hover { opacity: .9; }
.pw-reqs {
  margin: 6px 0 4px;
  padding-left: 18px;
  font-size: 12px;
  color: var(--muted, #888);
  line-height: 1.6;
}
.pw-toggle.shown {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24'/><line x1='1' y1='1' x2='23' y2='23'/></svg>");
}

/* --- History page --- */
.card-wide { max-width: 560px; }
.card-history { max-width: 900px; }
.history-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
@media (max-width: 700px) {
  .history-columns { grid-template-columns: 1fr; gap: 0; }
  .history-column + .history-column .history-heading { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
}
.history-list { list-style: none; margin: 0; padding: 0; text-align: left; }
.history-list li {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.history-list li:last-child { border-bottom: 0; }
.history-email { font-weight: 600; word-break: break-all; }
.history-detail { color: var(--muted); font-size: 14px; margin: 4px 0 8px; }
.history-test { color: var(--accent); font-weight: 700; }
.history-status {
  display: inline-block;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
}
.history-status.sent { color: #22a06b; background: #e7f6ef; }
.history-status.waiting { color: #b5750a; background: #fdf1dc; }
.history-meta { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.history-heading {
  margin: 28px 0 10px;
  font-size: 15px;
  text-align: left;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.history-heading:first-of-type { margin-top: 12px; padding-top: 0; border-top: 0; }
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
}
.pagination a { color: var(--panel); text-decoration: none; font-weight: 600; }

/* --- Mobile: stack tabs vertically --- */
@media (max-width: 480px) {
  .tabs { flex-direction: column; }
  .tab { padding: 24px 20px; flex-direction: row; gap: 14px; }
  h1 { font-size: 24px; }
  .history-btn { top: 12px; right: 12px; padding: 8px 14px; }
  .history-btn.corner-left { right: auto; left: 12px; }
  .user-menu { top: 12px; right: 12px; }
  .user-menu-btn { font-size: 12px; padding: 4px 12px 4px 4px; }
  .user-avatar { width: 28px; height: 28px; font-size: 12px; }
  .user-name { max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
