:root {
  --navy-deep: #0d1b2a;
  --navy: #1b263b;
  --slate: #415a77;
  --muted: #778da9;
  --deep-teal: #264653;
  --teal: #2a9d8f;
  --teal-bright: #3cb8a9;
  --surface: #f3f6f5;
  --text: #0d1b2a;
  --text-soft: #415a77;
  --border: rgba(13, 27, 42, 0.12);
  --focus-ring: rgba(42, 157, 143, 0.35);
  --error: #b42318;
  --ok: #1f6f5b;
  --font-display: "Sora", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
}

body {
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(42, 157, 143, 0.2), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 80%, rgba(38, 70, 83, 0.14), transparent 50%),
    linear-gradient(165deg, #e8f0ee 0%, var(--surface) 45%, #dfe8e6 100%);
  line-height: 1.55;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: var(--teal);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--deep-teal);
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  padding: 0.65rem 1rem;
  background: var(--navy-deep);
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 1rem;
}

.page {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: relative;
  z-index: 1;
  padding: 1.25rem 1.5rem 0;
  max-width: 28rem;
  width: 100%;
  margin: 0 auto;
}

.topbar-wide {
  position: sticky;
  top: 0;
  z-index: 40;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0.85rem max(1.5rem, calc((100% - 72rem) / 2));
  box-sizing: border-box;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(238, 243, 242, 0.82);
  border-bottom: 1px solid var(--border);
}

.topbar-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.account-top-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
}

.account-top-actions .btn-compact {
  padding: 0.55rem 0.95rem;
  font-size: 0.92rem;
  border-radius: 10px;
}

.account-menu {
  position: relative;
}

.account-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--deep-teal);
  cursor: pointer;
}

.account-menu-toggle:hover,
.account-menu-toggle[aria-expanded="true"] {
  border-color: var(--teal);
  color: var(--teal);
}

.hamburger {
  display: grid;
  gap: 0.28rem;
  width: 1.05rem;
}

.hamburger span {
  display: block;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.account-menu-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 5;
  min-width: 11.5rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 14px 30px rgba(13, 27, 42, 0.12);
}

.account-menu-item {
  display: block;
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--navy-deep);
  font: 600 0.95rem var(--font-body);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.account-menu-item:hover {
  background: #f3f7f6;
  color: var(--deep-teal);
}

.account-menu-item[hidden] {
  display: none !important;
}

.form-field[hidden] {
  display: none !important;
}

.account-top-actions .btn-primary.btn-compact {
  box-shadow: 0 4px 12px rgba(42, 157, 143, 0.22);
}

.pay-qr-block {
  display: grid;
  gap: 0.75rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border);
}

.pay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pay-actions[hidden] {
  display: none !important;
}

.pay-qr-block[hidden],
.pay-qr-card[hidden] {
  display: none !important;
}

.pay-qr-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

@media (max-width: 520px) {
  .pay-qr-grid {
    grid-template-columns: 1fr;
  }
}

.pay-qr-card {
  margin: 0;
  display: grid;
  gap: 0.5rem;
  justify-items: center;
  text-align: center;
  padding: 0.85rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f7faf9;
}

.pay-qr-card img {
  width: 200px;
  height: 200px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
}

.pay-qr-card figcaption {
  display: grid;
  gap: 0.15rem;
  font-size: 0.9rem;
  color: var(--text-soft);
}

.pay-qr-card figcaption strong {
  color: var(--navy-deep);
  font-size: 0.95rem;
}

.pay-qr-card figcaption span:empty {
  display: none;
}

.account-settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.account-settings-panel .admin-payment-form {
  max-width: 22rem;
  gap: 0.75rem;
}

.account-settings-panel .form-field input {
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  font-size: 0.92rem;
}

.account-settings-panel .btn {
  width: auto;
  min-width: 0;
  justify-self: start;
  padding: 0.55rem 0.95rem;
  font-size: 0.92rem;
  line-height: 1.2;
  border-radius: 10px;
  box-shadow: none;
}

.account-panel-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 600 0.9rem var(--font-body);
  cursor: pointer;
}

.account-panel-close:hover {
  color: var(--deep-teal);
}

.license-keys {
  display: grid;
  gap: 1rem;
  padding: 0.35rem 0 0.15rem;
}

.license-keys[hidden],
.license-block[hidden] {
  display: none !important;
}

.license-keys-title {
  margin: 0;
  font: 700 1rem var(--font-display, var(--font-body));
  color: var(--navy-deep);
}

.btn.btn-copy-key {
  flex: 0 0 auto;
  align-self: center;
  width: auto;
  max-width: none;
  min-width: 0;
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: 8px;
  white-space: nowrap;
  box-shadow: none;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
  color: var(--deep-teal);
  text-decoration: none;
}

.back-link:hover {
  color: var(--teal);
}

.auth-main,
.account-main {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: 28rem;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 2.5rem;
}

.account-main-wide {
  max-width: 72rem;
  justify-content: flex-start;
  gap: 1.25rem;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 1.25rem;
}

.brand-mark img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.brand-mark span {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--deep-teal);
}

.headline {
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 4.2vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--navy-deep);
  margin-bottom: 0.65rem;
}

.lede {
  font-size: 1.02rem;
  color: var(--text-soft);
  margin-bottom: 1.5rem;
}

.auth-card,
.account-card {
  display: grid;
  gap: 1.1rem;
  padding: 1.5rem 1.35rem 1.5rem;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(13, 27, 42, 0.08);
  backdrop-filter: blur(8px);
}

/* .account-card { display: grid } would otherwise beat the HTML hidden attribute */
.account-card[hidden],
.admin-card[hidden],
#admin-selected[hidden],
.account-settings-panel[hidden],
.account-menu-panel[hidden],
.modal-overlay[hidden] {
  display: none !important;
}

.form-field {
  display: grid;
  gap: 0.4rem;
}

.form-field label {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--deep-teal);
}

.form-field input {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: 500 1rem var(--font-body);
  color: var(--text);
  background: #fff;
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 2.75rem;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.45rem;
  translate: 0 -50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--slate);
  cursor: pointer;
}

.password-toggle:hover {
  color: var(--deep-teal);
  background: rgba(38, 70, 83, 0.06);
}

.password-toggle:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 1px;
}

.form-field input:focus {
  outline: none;
  border-color: rgba(42, 157, 143, 0.55);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-status {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 500;
}

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

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

.form-status[hidden] {
  display: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.85rem 1.5rem;
  border: none;
  border-radius: 10px;
  font: 600 1rem var(--font-body);
  cursor: pointer;
  text-decoration: none;
  transition: transform 200ms var(--ease), box-shadow 200ms var(--ease), opacity 200ms var(--ease);
}

.btn:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, var(--teal-bright), var(--teal));
  color: #fff;
  box-shadow: 0 10px 24px rgba(42, 157, 143, 0.28);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn-secondary {
  background: #fff;
  color: var(--deep-teal);
  border: 1px solid var(--border);
}

.btn-danger {
  background: #fff;
  color: #9f1239;
  border: 1px solid rgba(190, 18, 60, 0.35);
}

.btn-danger:hover:not(:disabled) {
  background: #fff1f2;
  border-color: #be123c;
}

body.modal-open {
  overflow: hidden;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(13, 27, 42, 0.45);
  backdrop-filter: blur(2px);
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal-dialog {
  width: min(100%, 24rem);
  margin: auto;
  max-height: calc(100dvh - 2.5rem);
  overflow-y: auto;
  padding: 1.35rem 1.35rem 1.25rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: #fff;
  box-shadow: 0 24px 48px rgba(13, 27, 42, 0.22);
}

.modal-title {
  margin: 0 0 0.4rem;
  font: 700 1.15rem var(--font-display, var(--font-body));
  color: var(--navy-deep);
}

.modal-copy {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  color: var(--text-soft);
}

.modal-form {
  display: grid;
  gap: 0.9rem;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.auth-switch {
  text-align: center;
  font-size: 0.95rem;
  color: var(--slate);
  margin-top: 0.25rem;
}

.field-aside {
  margin: -0.35rem 0 0;
  text-align: right;
  font-size: 0.92rem;
}

.field-aside a {
  font-weight: 600;
}

.account-meta {
  display: grid;
  gap: 0.35rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.account-meta dt {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.account-meta dd {
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy-deep);
  word-break: break-all;
}

.account-note {
  font-size: 0.95rem;
  color: var(--text-soft);
}

.license-block {
  display: grid;
  gap: 0.4rem;
  padding: 0.55rem 0 0.15rem;
  max-width: 30rem;
}

.license-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.license-key-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.license-key {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f7faf9;
  font: 600 0.82rem/1.4 ui-monospace, "Cascadia Code", Consolas, monospace;
  color: var(--navy-deep);
  word-break: break-all;
  white-space: pre-wrap;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.account-actions .btn {
  width: auto;
}


.admin-roster-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
}

.admin-roster-head .btn {
  width: auto;
  min-width: 7rem;
}

.roster-filter {
  margin: 0.35rem 0 0.15rem;
}

.table-wrap-tall {
  max-height: 28rem;
}

.payments-table tr.is-renewal-due td {
  background: rgba(233, 196, 106, 0.22);
}

.payments-table .mono {
  font: 600 0.78rem/1.35 ui-monospace, "Cascadia Code", Consolas, monospace;
  word-break: break-all;
}

.payments-table .btn-table {
  width: auto;
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
}

.btn-compact {
  width: auto;
  min-width: 0;
  padding: 0.55rem 0.95rem;
  font-size: 0.92rem;
  line-height: 1.2;
  border-radius: 10px;
  box-shadow: none;
  justify-self: start;
}

.plan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.plan-actions .btn {
  width: auto;
}

.admin-key-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  max-width: 100%;
}

/* Match paid key max width; leave room for Enable/Suspend beside it */
.admin-main .form-field #customer-trial-key,
.admin-main .form-field #customer-paid-key {
  flex: 1 1 auto;
  width: 28rem;
  max-width: calc(100% - 10.5rem);
  min-width: 0;
}

.trial-key-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 0.5rem;
}

.renewal-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: rgba(231, 111, 81, 0.16);
  color: #9a3412;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.admin-main {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: 100%;
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2.5rem;
  box-sizing: border-box;
}

.admin-card {
  margin-bottom: 1.25rem;
}

.admin-section-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy-deep);
  margin: 0.35rem 0 0.15rem;
}

.admin-search {
  display: grid;
  gap: 0.85rem;
}

.admin-results {
  list-style: none;
  display: grid;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.admin-result-btn {
  width: 100%;
  text-align: left;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font: 600 0.95rem var(--font-body);
  color: var(--navy-deep);
  cursor: pointer;
}

.admin-result-btn:hover {
  border-color: rgba(42, 157, 143, 0.45);
  background: #f7faf9;
}

.admin-payment-form {
  display: grid;
  gap: 0.85rem;
}

.form-row {
  display: grid;
  gap: 0.85rem;
}

.form-row-csv,
.form-row-tight {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem;
}

.form-row-csv .form-field,
.form-row-tight .form-field {
  margin: 0;
}

.form-row-csv .btn,
.form-row-tight .btn {
  width: auto;
}

.form-row-tight .form-field input[type="date"],
.form-row-tight .form-field input[type="number"],
.form-row-tight .form-field select {
  width: auto;
  min-width: 9.5rem;
}

@media (min-width: 640px) {
  .form-row:not(.form-row-csv):not(.form-row-tight) {
    grid-template-columns: 1fr 1fr;
  }

  .admin-search {
    grid-template-columns: 1fr auto;
    align-items: end;
  }

  .admin-search .btn {
    width: auto;
    min-width: 8rem;
  }
}

.field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.form-field-action .label-spacer {
  display: block;
  min-height: 1.35rem;
}

.form-field select,
.form-field textarea {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: 500 1rem var(--font-body);
  color: var(--text);
  background: #fff;
}

.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: rgba(42, 157, 143, 0.55);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.admin-check {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin: 0.15rem 0 0.35rem;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-soft);
  cursor: pointer;
}

.admin-check input {
  margin-top: 0.2rem;
  width: 1rem;
  height: 1rem;
  accent-color: var(--teal);
  flex-shrink: 0;
}

/* Compact controls on payment admin — don’t stretch across the wide layout */
.admin-main .form-field {
  justify-items: start;
}

.admin-main .form-field select {
  width: 13.5rem;
  max-width: 100%;
  min-width: 0;
  padding: 0.45rem 2rem 0.45rem 0.7rem;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.3;
}

.admin-main .form-field input[type="date"],
.admin-main .form-field input[type="number"],
.admin-main .form-field input[type="datetime-local"],
.modal-form input[type="datetime-local"] {
  width: 13.5rem;
  max-width: 100%;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

.modal-form input[type="datetime-local"] {
  width: 100%;
}

.admin-main .form-field input[type="text"],
.admin-main .form-field input[type="search"] {
  width: min(100%, 28rem);
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

.admin-main .form-field textarea {
  width: min(100%, 36rem);
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

.admin-empty {
  font-size: 0.95rem;
  color: var(--text-soft);
  padding: 0.35rem 0;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.payments-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.payments-table th,
.payments-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.payments-table th {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: #f7faf9;
}

.payments-table tr:last-child td {
  border-bottom: 0;
}

.payments-block {
  display: grid;
  gap: 0.65rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border);
}

.payments-block h2 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy-deep);
}

.footer {
  position: relative;
  z-index: 1;
  padding: 1rem 1.5rem 1.75rem;
  text-align: center;
  font-size: 0.88rem;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .orbit-a,
  .orbit-b {
    animation: none;
  }
}
