:root {
  --bg: #f7f8f4;
  --paper: #ffffff;
  --ink: #151719;
  --muted: #66717c;
  --line: rgba(21, 23, 25, .13);
  --green: #087932;
  --orange: #a95b00;
  --danger: #9f1d1d;
  --shadow: 0 14px 34px rgba(21, 23, 25, .10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(8, 168, 63, .10), transparent 26%),
    radial-gradient(circle at 88% 10%, rgba(244, 173, 52, .16), transparent 26%),
    var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(480px, 100%);
  background: rgba(255, 255, 255, .9);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand-line {
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 8px;
}

.login-card h1 {
  margin: 0;
  font-size: clamp(31px, 5.4vw, 44px);
  line-height: .94;
  letter-spacing: -0.06em;
}

.login-card p {
  color: var(--muted);
  line-height: 1.45;
}

.primary-button,
.secondary-button,
.logout-button,
.nav-button {
  border: 0;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  min-height: 48px;
  background: var(--green);
  color: white;
  font-size: 17px;
}

.secondary-button {
  width: 100%;
  min-height: 44px;
  background: #151719;
  color: white;
  font-size: 15px;
  margin-top: 12px;
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: .55;
  cursor: default;
}

.code-panel {
  margin-top: 22px;
}

.code-boxes {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 14px 0 16px;
}

.code-boxes input {
  width: 100%;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  text-align: center;
  font-size: 28px;
  font-weight: 750;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

.code-boxes input:focus {
  outline: 2px solid rgba(8, 121, 50, .25);
  border-color: rgba(8, 121, 50, .55);
}

.status {
  min-height: 22px;
  color: var(--muted);
  font-size: 14px;
  margin-top: 12px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

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

.status.ok {
  color: var(--green);
}

.admin-shell {
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.admin-topbar {
  min-height: 68px;
  background: rgba(255, 255, 255, .86);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
  backdrop-filter: blur(12px);
}

.admin-title {
  font-size: 22px;
  line-height: 1;
  font-weight: 750;
  letter-spacing: -0.04em;
  white-space: nowrap;
}

.admin-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.admin-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.admin-nav::-webkit-scrollbar {
  display: none;
}

.nav-button {
  padding: 8px 13px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.nav-button.active {
  background: #151719;
  color: white;
}

.logout-button {
  padding: 8px 14px;
  background: #fff;
  border: 1px solid var(--line);
  color: #151719;
  white-space: nowrap;
}

.admin-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}

.content-page {
  padding: 22px;
}

.content-page h1 {
  margin: 0 0 16px;
  font-size: clamp(32px, 5vw, 50px);
  line-height: 1;
  letter-spacing: -0.055em;
}

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

.admin-card {
  background: rgba(255,255,255,.88);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(21,23,25,.06);
}

.admin-card h2 {
  margin: 0 0 12px;
  font-size: 24px;
  letter-spacing: -0.035em;
}

.metric {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.metric-block strong {
  display: block;
  font-size: 34px;
  line-height: 1;
  letter-spacing: -0.055em;
}

.metric-block span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 5px;
}

.table-card {
  background: rgba(255,255,255,.88);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  text-align: left;
  padding: 10px 9px;
  border-bottom: 1px solid rgba(21, 23, 25, .10);
  font-size: 14px;
}

th {
  color: var(--muted);
  font-weight: 700;
}

.placeholder {
  background: rgba(255,255,255,.88);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 24px;
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 760px) {
  .admin-shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .admin-topbar {
    grid-template-columns: 1fr auto;
  }

  .admin-nav {
    grid-column: 1 / -1;
    order: 3;
  }

  .admin-frame {
    min-height: calc(100dvh - 116px);
  }

  .card-grid {
    grid-template-columns: 1fr;
  }
}


/* v5 compact admin login */
.login-card.compact-login {
  width: min(430px, 100%);
  padding: 24px 26px;
  border-radius: 22px;
}

.compact-login .brand-line {
  font-size: 22px;
  margin-bottom: 10px;
}

.compact-login .login-help {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.35;
}

.compact-login .primary-button {
  min-height: 44px;
  font-size: 16px;
}

.compact-code-panel {
  margin-top: 16px;
}

.code-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 650;
}

.code-row input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  padding: 0 13px;
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 22px;
  font-weight: 750;
  letter-spacing: .16em;
  text-align: center;
}

.code-row input::placeholder {
  color: rgba(102, 113, 124, .42);
}

.code-row input:focus {
  outline: 2px solid rgba(8, 121, 50, .22);
  border-color: rgba(8, 121, 50, .55);
}

.compact-login .secondary-button {
  min-height: 40px;
  margin-top: 12px;
  font-size: 15px;
}

.compact-login .status {
  margin-top: 12px;
  min-height: 20px;
}

@media (max-width: 520px) {
  .login-page {
    padding: 16px;
  }

  .login-card.compact-login {
    padding: 22px 20px;
  }

  .code-row {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .code-row input {
    text-align: left;
    letter-spacing: .12em;
  }
}


/* v6: plain Go Back link on admin login */
.back-link-row {
  margin-top: 10px;
  text-align: center;
}

.back-link {
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}
