:root {
  --bg-1: #f1f7ff;
  --bg-2: #dcecff;
  --bg-3: #c0dcff;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: rgba(255, 255, 255, 0.95);
  --line: rgba(59, 130, 246, 0.18);
  --text: #10233a;
  --muted: #4b647f;
  --accent: #2682ff;
  --accent-strong: #0f6ae6;
  --success: #168a57;
  --warning: #b7791f;
  --danger: #c0392b;
  --shadow: 0 18px 44px rgba(25, 55, 100, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, .92) 0%, rgba(241, 247, 255, .96) 24%, rgba(207, 228, 255, .98) 58%, #bddbff 100%),
    linear-gradient(180deg, #f7fbff 0%, #d9ebff 100%);
}

.access-body {
  min-height: 100dvh;
  overflow: hidden;
}

.admin-body {
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
}

.access-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.admin-shell {
  min-height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
}

.access-hero,
.admin-card {
  width: min(980px, 100%);
  background: linear-gradient(180deg, rgba(255, 255, 255, .92) 0%, rgba(248, 252, 255, .98) 100%);
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.access-hero {
  min-height: min(86dvh, 720px);
  max-height: calc(100dvh - 36px);
  padding: clamp(20px, 3vw, 34px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  overflow: hidden;
}

.admin-card {
  margin: 0 auto;
  padding: clamp(18px, 2.2vw, 26px);
}

.admin-card.narrow {
  width: min(580px, 100%);
}

.access-logo-wrap {
  width: min(42vw, 260px);
  max-width: 260px;
  margin-bottom: 14px;
  display: grid;
  place-items: center;
}

.access-logo {
  display: block;
  width: min(100%, 230px);
  max-height: 230px;
  object-fit: contain;
  filter: drop-shadow(0 12px 24px rgba(59, 130, 246, 0.14));
}

.access-kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: .24em;
  font-size: clamp(.76rem, 1.4vw, .95rem);
  color: #3d6da8;
  font-weight: 800;
}

.access-hero h1,
.admin-card h1 {
  margin: 0;
  color: #0e2238;
  line-height: .98;
  letter-spacing: -.04em;
}

.access-hero h1 {
  font-size: clamp(2.4rem, 6vw, 5rem);
}

.admin-card h1 {
  font-size: clamp(1.7rem, 3.5vw, 2.6rem);
}

.access-subtitle,
.admin-text,
.modal-text {
  margin: 12px auto 0;
  max-width: 640px;
  color: var(--muted);
  font-size: clamp(.98rem, 1.8vw, 1.14rem);
  line-height: 1.45;
}

.primary-access-button,
.secondary-button,
.input-action-button {
  border: none;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.primary-access-button,
.secondary-button {
  min-height: 54px;
  padding: 14px 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 800;
  font-size: 1rem;
  white-space: nowrap;
}

.primary-access-button {
  margin-top: 18px;
  background: linear-gradient(180deg, #3f97ff 0%, #1c7df0 100%);
  color: #fff;
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.18);
}

.primary-access-button:hover,
.secondary-button:hover,
.input-action-button:hover {
  transform: translateY(-1px);
}

.primary-access-button.full {
  width: 100%;
}

.secondary-button {
  background: #edf5ff;
  color: #235a9b;
  border: 1px solid rgba(37, 99, 235, 0.14);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(14, 27, 45, 0.42);
  backdrop-filter: blur(6px);
  z-index: 30;
}

.modal-backdrop.hidden {
  display: none;
}

.access-modal {
  position: relative;
  width: min(520px, 100%);
  background: var(--panel-strong);
  border: 1px solid rgba(37, 99, 235, 0.14);
  border-radius: 24px;
  box-shadow: 0 18px 44px rgba(14, 27, 45, 0.18);
  padding: 22px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(37, 99, 235, 0.12);
  background: #fff;
  color: #45627f;
  cursor: pointer;
  font-size: 1.35rem;
}

.modal-kicker {
  margin: 0;
  color: #3d6da8;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: .82rem;
}

.access-modal h2 {
  margin: 10px 0 0;
  font-size: clamp(1.5rem, 3vw, 2rem);
  line-height: 1.05;
}

.access-form,
.admin-form {
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

.form-label {
  font-weight: 700;
  color: #2a4565;
}

.access-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
}

.access-input {
  width: 100%;
  min-height: 56px;
  border-radius: 16px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  background: #fff;
  padding: 14px 16px;
  font-size: 1.05rem;
  color: #16304e;
}

.access-input:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.46);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.input-action-button {
  min-width: 92px;
  min-height: 56px;
  border-radius: 16px;
  background: #edf5ff;
  color: #215a9a;
  border: 1px solid rgba(37, 99, 235, 0.14);
  font-weight: 800;
}

.access-message {
  min-height: 24px;
  margin-top: 14px;
  font-size: .97rem;
  color: #3f5f81;
}

.access-message.error {
  color: var(--danger);
}

.access-message.success {
  color: var(--success);
}

.status-banner {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 16px;
  border: 1px solid transparent;
  line-height: 1.4;
}

.status-banner.info {
  background: #eff7ff;
  border-color: rgba(37, 99, 235, 0.1);
  color: #295f99;
}

.status-banner.warning {
  background: #fff7e8;
  border-color: rgba(217, 119, 6, 0.14);
  color: #8a5a11;
}

.admin-topbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.admin-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.admin-grid.single-gap {
  grid-template-columns: 1fr;
}

.admin-box {
  border-radius: 22px;
  padding: 16px 18px;
  background: #fff;
  border: 1px solid rgba(37, 99, 235, 0.1);
}

.admin-box.highlight {
  background: linear-gradient(180deg, #f5faff 0%, #edf6ff 100%);
}

.box-label {
  display: block;
  color: #4c6b8d;
  font-weight: 700;
  font-size: .92rem;
}

.code-badge {
  margin-top: 8px;
  font-size: clamp(1.8rem, 4.1vw, 2.5rem);
  letter-spacing: .12em;
  font-weight: 900;
  color: #0f2137;
  line-height: 1;
}

.code-badge.smaller {
  font-size: clamp(1.05rem, 3vw, 1.7rem);
  letter-spacing: .08em;
}

.code-badge[data-last-code] {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.state-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #eaf8ef;
  color: #167c4f;
  font-weight: 800;
}

.admin-list {
  margin: 14px 0 0;
  display: grid;
  gap: 10px;
}

.admin-list.compact {
  gap: 8px;
}

.admin-list div {
  display: grid;
  gap: 4px;
}

.admin-list dt {
  color: #5a738f;
  font-weight: 700;
}

.admin-list dd {
  margin: 0;
  color: #10233a;
  line-height: 1.35;
}

.admin-actions {
  margin-top: 14px;
}

.admin-actions .primary-access-button {
  margin-top: 0;
  width: 100%;
}

.mini-note {
  margin: 10px 0 0;
  color: #5d748d;
  line-height: 1.4;
}

.mini-note.spaced {
  margin-top: 14px;
}

.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;
}

@media (max-width: 900px) {
  .admin-topbar {
    flex-direction: column;
  }

  .admin-topbar form {
    align-self: flex-end;
  }
}

@media (max-width: 760px) {
  .access-shell,
  .admin-shell {
    padding: 12px;
  }

  .access-hero {
    min-height: calc(100dvh - 24px);
    max-height: calc(100dvh - 24px);
  }

  .admin-grid,
  .admin-grid.single-gap {
    grid-template-columns: 1fr;
  }

  .admin-card {
    padding: 16px;
    border-radius: 22px;
  }

  .admin-box {
    padding: 15px 16px;
    border-radius: 18px;
  }

  .secondary-button,
  .primary-access-button {
    width: 100%;
  }

  .admin-topbar form {
    width: 100%;
    align-self: stretch;
  }
}

@media (max-height: 820px) {
  .admin-shell {
    padding: 10px;
  }

  .admin-card {
    padding: 16px 18px;
  }

  .admin-card h1 {
    font-size: clamp(1.5rem, 3vw, 2.1rem);
  }

  .status-banner,
  .admin-grid,
  .admin-actions,
  .mini-note.spaced {
    margin-top: 12px;
  }

  .admin-box {
    padding: 14px 16px;
  }

  .code-badge {
    font-size: clamp(1.55rem, 3.4vw, 2.15rem);
  }

  .code-badge.smaller {
    font-size: clamp(1rem, 2.5vw, 1.45rem);
  }
}

@media (max-height: 760px) {
  .access-hero {
    min-height: calc(100dvh - 24px);
    max-height: calc(100dvh - 24px);
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .access-logo-wrap {
    width: min(30vw, 180px);
    margin-bottom: 8px;
  }

  .access-subtitle {
    margin-top: 8px;
  }

  .primary-access-button {
    margin-top: 14px;
  }
}

.admin-card-wide {
  width: min(1180px, 100%);
}

.admin-text.compact {
  margin-top: 10px;
  max-width: 760px;
}

.admin-grid.admin-grid-top {
  align-items: stretch;
}

.admin-summary-box,
.admin-last-box {
  min-height: 100%;
}

.summary-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.summary-count {
  font-size: clamp(2.1rem, 4.4vw, 3rem);
  line-height: 1;
  font-weight: 900;
  color: #0f2137;
}

.admin-actions.inline {
  margin-top: 0;
  flex-shrink: 0;
}

.admin-actions.inline .primary-access-button {
  width: auto;
  margin-top: 0;
}

.admin-refresh-note {
  min-height: 22px;
}

.admin-refresh-note.ok {
  color: var(--success);
}

.admin-refresh-note.error {
  color: var(--danger);
}

.admin-box-spaced {
  margin-top: 14px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.section-head.with-counter {
  align-items: center;
}

.section-note {
  margin-top: 6px;
}

.history-counter {
  min-width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #edf5ff;
  color: #1e5d9f;
  font-weight: 800;
}

.code-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.code-card {
  border-radius: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(37, 99, 235, 0.12);
  background: linear-gradient(180deg, #fbfdff 0%, #f1f8ff 100%);
  display: grid;
  gap: 8px;
}

.code-card-label {
  color: #4b6c8e;
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.code-card-value {
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1;
  letter-spacing: .12em;
  color: #10233a;
}

.code-card-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.copy-code-button {
  border: 1px solid rgba(37, 99, 235, 0.18);
  background: #eaf4ff;
  color: #1d5f9f;
  border-radius: 999px;
  min-height: 34px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 800;
  font-size: .86rem;
  transition: transform .15s ease, background .15s ease, color .15s ease;
}

.copy-code-button:hover {
  transform: translateY(-1px);
  background: #dbeeff;
}

.copy-code-button.compact {
  min-height: 30px;
  padding: 6px 10px;
  font-size: .78rem;
  letter-spacing: 0;
}

.copy-code-button.copied {
  background: #eaf8ef;
  color: var(--success);
  border-color: rgba(22, 138, 87, .2);
}

.code-card-meta {
  color: #66809b;
  font-size: .92rem;
}

.history-scroll {
  margin-top: 14px;
  max-height: 390px;
  overflow-y: auto;
  padding-right: 6px;
  display: grid;
  gap: 12px;
}

.history-card {
  border-radius: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(37, 99, 235, 0.11);
  background: #fff;
}

.history-card.pending {
  background: linear-gradient(180deg, #fffdf7 0%, #fffaf0 100%);
  border-color: rgba(217, 119, 6, 0.16);
}

.history-card.completed {
  background: linear-gradient(180deg, #f8fcff 0%, #f0f8ff 100%);
}

.history-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-code {
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: .12em;
  color: #0f2137;
}

.history-status {
  margin-left: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 800;
}

.history-status.completed {
  background: #eaf8ef;
  color: #177c50;
}

.history-status.pending {
  background: #fff4df;
  color: #a86911;
}

.history-date {
  color: #5d748d;
  font-size: .94rem;
  text-align: right;
}

.history-meta-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.history-meta-label {
  display: block;
  color: #68809a;
  font-size: .82rem;
  font-weight: 700;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.history-empty {
  border-radius: 18px;
  padding: 18px;
  background: #f6fbff;
  border: 1px dashed rgba(37, 99, 235, 0.16);
  color: #55718e;
}

.admin-list-tight {
  margin-top: 12px;
}

@media (max-width: 980px) {
  .code-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .summary-row,
  .section-head,
  .section-head.with-counter,
  .history-card-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .admin-actions.inline,
  .admin-actions.inline .primary-access-button {
    width: 100%;
  }

  .code-grid,
  .history-meta-grid {
    grid-template-columns: 1fr;
  }

  .history-date {
    text-align: left;
  }
}

.history-card.in_progress {
  background: linear-gradient(180deg, #f8fbff 0%, #eef6ff 100%);
  border-color: rgba(37, 99, 235, 0.18);
}

.history-card.error {
  background: linear-gradient(180deg, #fff7f7 0%, #fff1f1 100%);
  border-color: rgba(220, 38, 38, 0.18);
}

.history-status.in_progress {
  background: #eaf2ff;
  color: #1d4ed8;
}

.history-status.error {
  background: #fee2e2;
  color: #b91c1c;
}

.history-meta-grid small {
  display: block;
  margin-top: 3px;
  color: #64748b;
  font-weight: 700;
}
