:root {
  color-scheme: light;
  --bg: #fff7eb;
  --paper: #ffffff;
  --paper-soft: #fffaf2;
  --ink: #172033;
  --muted: #687084;
  --line: #eadfd1;
  --line-strong: #d8c8b7;
  --brand: #ff6b35;
  --blue: #1268f3;
  --green: #16b886;
  --yellow: #ffd166;
  --danger: #d9475b;
  --shadow: 0 22px 60px rgba(52, 38, 22, 0.14);
  font-family: "Aptos Display", "Segoe UI", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { overflow-x: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 8%, rgba(255, 209, 102, 0.48), transparent 28%),
    radial-gradient(circle at 92% 12%, rgba(18, 104, 243, 0.17), transparent 26%),
    linear-gradient(135deg, #fff7eb 0%, #f6fbff 52%, #eefaf2 100%);
  color: var(--ink);
}
button, input, select, textarea { font: inherit; }
button { border: 0; }
a { color: inherit; }

.portal-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 0 42px;
}
.site-topbar {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 74px;
  border: 1px solid rgba(234, 223, 209, 0.9);
  border-radius: 24px;
  padding: 13px 16px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 34px rgba(52, 38, 22, 0.08);
  backdrop-filter: blur(18px);
}
.brand {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  text-decoration: none;
}
.brand img {
  width: 178px;
  max-height: 48px;
  object-fit: contain;
}
.top-nav {
  display: flex;
  justify-content: center;
  flex: 1 1 auto;
  gap: 8px;
}
.nav-item {
  min-height: 42px;
  border-radius: 999px;
  padding: 10px 16px;
  color: #465068;
  background: transparent;
  cursor: pointer;
}
.nav-item:hover, .nav-item.active {
  color: #06111f;
  background: #ffe2bd;
}
.account-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}
.page-heading {
  margin: 30px 0 18px;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(34px, 5vw, 58px); line-height: 0.96; }
h2 { margin-bottom: 8px; font-size: 23px; }
h3 { margin-bottom: 8px; font-size: 18px; }
.muted, small, .section-heading p { color: var(--muted); }

.auth-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 430px;
  gap: clamp(28px, 6vw, 72px);
  align-items: start;
  padding-top: clamp(34px, 6vh, 70px);
}
.auth-copy {
  max-width: 640px;
}
.auth-copy h2 {
  max-width: 660px;
  margin-bottom: 22px;
  font-size: clamp(44px, 7vw, 86px);
  line-height: 0.92;
  letter-spacing: -0.055em;
}
.auth-copy p {
  max-width: 560px;
  color: #37415a;
  font-size: 18px;
  line-height: 1.65;
}
.auth-points {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}
.auth-points span {
  border: 1px solid #f2c896;
  border-radius: 999px;
  padding: 9px 13px;
  background: rgba(255, 255, 255, 0.66);
  color: #704313;
  font-weight: 750;
}
.auth-panel, .card, .metric, .table-card {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}
.auth-panel {
  display: grid;
  gap: 18px;
  padding: 26px;
}
.tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: 6px;
  background: #fff6ea;
}
.tabs button {
  min-height: 44px;
  border-radius: 13px;
  color: #5c6475;
  background: transparent;
  cursor: pointer;
}
.tabs button.active {
  color: #15191f;
  background: var(--yellow);
  font-weight: 900;
  box-shadow: 0 10px 20px rgba(255, 184, 77, 0.2);
}
.form-stack, .form-grid { display: grid; gap: 15px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wide { grid-column: 1 / -1; }
label {
  display: grid;
  gap: 7px;
  color: #333d55;
  font-size: 13px;
  font-weight: 700;
}
input, select, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #fffdf9;
  color: var(--ink);
  padding: 12px 14px;
  outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(18, 104, 243, 0.12);
}
.captcha-box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 1px solid #d7dfe7;
  border-radius: 16px;
  padding: 13px 14px;
  background: #f8fbff;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.captcha-box:hover {
  border-color: #9fb3d0;
  background: #f1f7ff;
}
.captcha-box:focus-visible {
  outline: 3px solid rgba(18, 104, 243, 0.2);
  outline-offset: 2px;
}
.captcha-box:disabled {
  cursor: wait;
}
.captcha-tick {
  width: 30px;
  height: 30px;
  border: 2px solid #adb8c5;
  border-radius: 7px;
  background: white;
}
.captcha-box.is-busy .captcha-tick {
  border-color: var(--blue);
  border-top-color: transparent;
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}
.captcha-box.is-ok .captcha-tick {
  border-color: var(--green);
  background:
    linear-gradient(135deg, transparent 48%, white 50%) 8px 13px / 7px 12px no-repeat,
    linear-gradient(45deg, transparent 48%, white 50%) 14px 8px / 13px 18px no-repeat,
    var(--green);
}
.captcha-box.is-error {
  border-color: rgba(217, 71, 91, 0.42);
  background: rgba(217, 71, 91, 0.08);
}
.captcha-box.is-error .captcha-tick {
  border-color: var(--danger);
  background:
    linear-gradient(45deg, transparent 43%, var(--danger) 45%, var(--danger) 55%, transparent 57%) center / 16px 16px no-repeat,
    linear-gradient(-45deg, transparent 43%, var(--danger) 45%, var(--danger) 55%, transparent 57%) center / 16px 16px no-repeat,
    white;
}
.captcha-box strong {
  display: block;
  color: #172033;
  font-size: 15px;
}
.captcha-box small { display: block; margin-top: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.primary, .secondary, .ghost, .danger-button, .link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 14px;
  padding: 10px 16px;
  text-decoration: none;
  cursor: pointer;
}
.primary {
  color: #06111f;
  background: linear-gradient(135deg, #ffd166, #47dfad);
  font-weight: 900;
}
.secondary {
  color: white;
  background: #1b5fd1;
}
.ghost, .link-button {
  color: #34405a;
  border: 1px solid var(--line-strong);
  background: white;
}
.link-button {
  justify-content: flex-start;
  min-height: auto;
  border-color: transparent;
  padding-left: 0;
  background: transparent;
}
.danger-button { color: white; background: var(--danger); }
button:disabled { cursor: not-allowed; opacity: 0.6; }
.small { min-height: 36px; padding: 8px 12px; font-size: 12px; }
.app-view {
  margin-top: 18px;
}
.view { display: none; }
.view.active { display: grid; gap: 18px; }
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.metric { padding: 19px; }
.metric span { display: block; color: var(--muted); font-size: 13px; }
.metric strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(20px, 2vw, 28px);
  line-height: 1.05;
}
.card, .table-card { padding: 24px; }
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.account-chip, .status-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid #b9c9ed;
  border-radius: 999px;
  padding: 8px 12px;
  background: #eef5ff;
  color: #16499f;
  font-size: 12px;
  white-space: nowrap;
}
.status-pill.good { border-color: rgba(22, 184, 134, 0.45); color: #0a7254; background: rgba(22, 184, 134, 0.1); }
.status-pill.warn { border-color: rgba(255, 184, 77, 0.7); color: #815214; background: rgba(255, 209, 102, 0.22); }
.status-pill.danger { border-color: rgba(217, 71, 91, 0.45); color: #a01f35; background: rgba(217, 71, 91, 0.1); }
.feature-list, .device-list, .user-list, .stack { display: grid; gap: 10px; }
.feature-list.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.feature-row, .device-item, .user-row, .plan-line {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper-soft);
  padding: 14px;
}
.feature-row { align-items: center; justify-content: flex-start; }
.feature-row span { min-width: 78px; color: #0c8d66; font-size: 12px; font-weight: 800; }
.feature-row.disabled span { color: var(--muted); }
.device-item, .user-row { align-items: center; }
.device-item strong, .user-row strong { display: block; }
.user-row { width: 100%; color: var(--ink); text-align: left; cursor: pointer; }
.user-row:hover { border-color: var(--blue); }
.plan-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.plan-card {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
  background: #fffdf9;
}
.plan-card.current, .plan-card.featured {
  border-color: rgba(18, 104, 243, 0.44);
  background: #f1f7ff;
}
.price-line strong { display: block; font-size: 32px; }
.price-line span { color: var(--muted); }
.plan-card ul { display: grid; gap: 8px; margin: 0; padding-left: 18px; color: var(--muted); }
.admin-layout { display: grid; grid-template-columns: minmax(290px, 0.85fr) minmax(420px, 1.15fr); gap: 16px; }
.search { margin-bottom: 12px; }
.empty {
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  padding: 18px;
  color: var(--muted);
  background: var(--paper-soft);
}
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  max-width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 13px 15px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .site-topbar { position: static; align-items: stretch; flex-direction: column; }
  .brand img { width: 164px; }
  .top-nav { width: 100%; justify-content: flex-start; overflow-x: auto; padding-bottom: 4px; }
  .account-actions { width: 100%; justify-content: space-between; }
  .auth-layout, .summary-grid, .plan-grid, .admin-layout { grid-template-columns: 1fr; }
  .auth-copy { max-width: none; }
}
@media (max-width: 640px) {
  .portal-shell { width: min(100% - 18px, 1180px); padding-top: 9px; }
  .site-topbar { border-radius: 18px; }
  .auth-layout { min-height: auto; padding: 24px 0; }
  .auth-copy h2 { font-size: 42px; }
  .auth-panel, .card, .table-card { padding: 18px; border-radius: 20px; }
  .section-heading, .device-item, .user-row, .feature-row { align-items: stretch; flex-direction: column; }
  .form-grid, .feature-list.compact { grid-template-columns: 1fr; }
  .actions a, .actions button, .account-actions button { width: 100%; }
}
