:root {
  color-scheme: light;
  --ink: #25343e;
  --ink-soft: #596a72;
  --green: #79b53b;
  --green-dark: #4f8f18;
  --green-pale: #eff7e3;
  --surface: #ffffff;
  --surface-muted: #f2f1ed;
  --line: #e2e0d9;
  --danger: #a63d3d;
  --danger-pale: #fff1f0;
  --shadow: 0 24px 70px rgba(37, 52, 62, 0.12);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #f6f5f1; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 12%, rgba(121, 181, 59, 0.14), transparent 30rem),
    linear-gradient(135deg, #f8f8f5 0%, #efeee9 100%);
}
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 10;
  padding: 10px 14px;
  color: #fff;
  background: var(--ink);
  border-radius: 8px;
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; }

.portal-header {
  min-height: 98px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(24px, 5vw, 76px);
  border-bottom: 1px solid rgba(37, 52, 62, 0.08);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px);
}
.brand img { display: block; width: min(260px, 44vw); height: auto; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}
.back-link:hover, .back-link:focus-visible { border-color: var(--green); color: var(--green-dark); }
.admin-link {
  color: #fff;
  border-color: var(--green-dark);
  background: var(--green-dark);
  box-shadow: 0 10px 22px rgba(79, 143, 24, 0.2);
}
.admin-link:hover, .admin-link:focus-visible {
  color: #fff;
  border-color: #427b12;
  background: #427b12;
}

.portal-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(56px, 9vw, 110px) 0 80px;
}
.portal-intro { max-width: 680px; margin-bottom: 42px; }
.eyebrow, .card-kicker {
  margin: 0 0 10px;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.portal-intro h1, .dashboard-heading h1 {
  margin: 0;
  font-size: clamp(2.5rem, 6vw, 5.6rem);
  line-height: 0.95;
  letter-spacing: -0.055em;
}
.portal-intro h1 span { color: var(--green-dark); }
.portal-intro > p:last-child {
  max-width: 620px;
  margin: 24px 0 0;
  color: var(--ink-soft);
  font-size: clamp(1.03rem, 2vw, 1.24rem);
  line-height: 1.65;
}

.portal-card {
  border: 1px solid rgba(37, 52, 62, 0.09);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}
.login-card { max-width: 620px; padding: clamp(24px, 5vw, 44px); }
.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}
.card-heading h2 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.35rem); letter-spacing: -0.035em; }
.security-note {
  padding: 7px 10px;
  color: var(--green-dark);
  background: var(--green-pale);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 750;
  white-space: nowrap;
}
form { display: grid; gap: 20px; }
label { display: grid; gap: 8px; color: var(--ink-soft); font-size: 0.9rem; font-weight: 700; }
input {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  color: var(--ink);
  border: 1px solid #cfcdc6;
  border-radius: 12px;
  outline: none;
  background: #fbfbf9;
}
input:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(121, 181, 59, 0.16); }
.password-control { position: relative; width: 100%; }
.password-control input { padding-right: 54px; }
.password-toggle {
  position: absolute;
  top: 50%;
  right: 7px;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--ink-soft);
  border: 0;
  border-radius: 9px;
  background: transparent;
}
.password-toggle:hover,
.password-toggle:focus-visible,
.password-toggle[aria-pressed="true"] {
  color: var(--green-dark);
  background: var(--green-pale);
}
.password-toggle:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.eye-icon {
  position: relative;
  width: 19px;
  height: 13px;
  display: block;
  border: 2px solid currentColor;
  border-radius: 75% 15%;
  transform: rotate(45deg);
}
.eye-icon::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 6px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}
.password-toggle[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  width: 25px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(-45deg);
}
.primary-button, .secondary-button, .release-button, .icon-button {
  border: 0;
  border-radius: 12px;
  font-weight: 800;
  transition: transform 140ms ease, background 140ms ease, opacity 140ms ease;
}
.text-button {
  justify-self: start;
  padding: 0;
  color: var(--green-dark);
  border: 0;
  background: transparent;
  font-weight: 750;
}
.text-button:hover, .text-button:focus-visible { text-decoration: underline; }
.account-copy { margin: 0 0 24px; color: var(--ink-soft); line-height: 1.6; }
.account-copy.is-error { color: var(--danger); }
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 20px;
  text-decoration: none;
}
.account-page { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, .75fr); gap: 64px; align-items: start; }
.account-page .login-card { margin-top: 24px; }
.form-status.is-success { color: var(--green-dark); }
.primary-button {
  min-height: 52px;
  padding: 0 20px;
  color: #fff;
  background: var(--green-dark);
  box-shadow: 0 12px 24px rgba(79, 143, 24, 0.22);
}
.primary-button:hover, .primary-button:focus-visible { background: #427b12; transform: translateY(-1px); }
button:disabled { cursor: wait; opacity: 0.58; transform: none !important; }
.privacy-note, .card-copy {
  margin: 18px 0 0;
  color: var(--ink-soft);
  font-size: 0.83rem;
  line-height: 1.5;
}
.form-status, .dashboard-status { min-height: 1.4em; margin: 0; color: var(--ink-soft); }
.form-status.is-error, .dashboard-status.is-error { color: var(--danger); }

.dashboard-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 42px;
}
.dashboard-heading h1 { font-size: clamp(2.4rem, 5vw, 4.6rem); }
.secondary-button {
  padding: 12px 17px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: var(--surface);
}
.secondary-button:hover, .secondary-button:focus-visible { border-color: var(--green); }
.dashboard-grid { display: grid; grid-template-columns: minmax(290px, 0.85fr) minmax(430px, 1.4fr); gap: 24px; }
.dashboard-grid .portal-card { padding: clamp(22px, 3vw, 34px); box-shadow: 0 18px 55px rgba(37, 52, 62, 0.09); }
.status-badge {
  padding: 7px 11px;
  color: var(--green-dark);
  background: var(--green-pale);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
}
.status-badge.is-inactive { color: var(--danger); background: var(--danger-pale); }
.entitlement {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-muted);
}
.entitlement + .entitlement { margin-top: 12px; }
.entitlement strong { display: block; font-size: 1.15rem; }
.entitlement-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 18px; }
.metric { padding: 12px; border-radius: 12px; background: var(--surface); }
.metric span { display: block; color: var(--ink-soft); font-size: 0.75rem; }
.metric strong { margin-top: 4px; font-size: 1rem; }
.icon-button {
  width: 38px;
  height: 38px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: var(--surface-muted);
  font-size: 1.3rem;
}
.device-list { display: grid; gap: 12px; margin-top: 22px; }
.device {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfbf9;
}
.device h3 { margin: 0; overflow-wrap: anywhere; font-size: 1.02rem; }
.device p { margin: 6px 0 0; color: var(--ink-soft); font-size: 0.8rem; line-height: 1.45; }
.release-button {
  padding: 10px 13px;
  color: var(--danger);
  border: 1px solid #edc4c1;
  background: var(--danger-pale);
}
.release-button:hover, .release-button:focus-visible { background: #ffe3e0; }
.empty-state {
  padding: 24px;
  color: var(--ink-soft);
  text-align: center;
  border: 1px dashed #c9c6bc;
  border-radius: 16px;
  background: var(--surface-muted);
}
.dashboard-status { margin-top: 20px; }

.portal-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 26px clamp(24px, 5vw, 76px);
  color: var(--ink-soft);
  border-top: 1px solid rgba(37, 52, 62, 0.09);
  font-size: 0.8rem;
}
.portal-footer a { color: inherit; }

@media (max-width: 820px) {
  .account-page { grid-template-columns: 1fr; gap: 24px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-heading { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 560px) {
  .portal-header { min-height: 82px; flex-wrap: wrap; padding: 14px 20px; }
  .brand img { width: 190px; }
  .header-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .back-link { padding: 9px 11px; font-size: 0.78rem; }
  .portal-shell { width: min(100% - 24px, 1180px); padding-top: 46px; }
  .portal-card { border-radius: 18px; }
  .card-heading { align-items: flex-start; flex-direction: column; }
  .device { grid-template-columns: 1fr; }
  .release-button { width: 100%; }
  .portal-footer { flex-direction: column; padding: 24px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
