:root {
  color-scheme: dark;
  --bg: #0b0e0e;
  --surface: #121616;
  --surface-2: #171b1a;
  --paper: #f3ede2;
  --muted: #aaa79f;
  --quiet: #747873;
  --line: rgba(243, 237, 226, 0.12);
  --line-strong: rgba(201, 154, 75, 0.34);
  --amber: #c99a4b;
  --amber-light: #e3bc76;
  --green: #67c89a;
  --red: #d96b66;
  --blue: #7da7c8;
  --header-height: 68px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--paper);
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0;
}

button,
input { font: inherit; letter-spacing: 0; }

button,
a { -webkit-tap-highlight-color: transparent; }

a { color: inherit; }

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--amber-light);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  background: var(--paper);
  color: var(--bg);
  transform: translateY(-140%);
}

.skip-link:focus { transform: translateY(0); }

.portal-grid {
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  opacity: 0.42;
  background-image:
    linear-gradient(rgba(243, 237, 226, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(243, 237, 226, 0.025) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: linear-gradient(to bottom, #000 0, transparent 88%);
}

.portal-header {
  position: sticky;
  z-index: 20;
  top: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(11, 14, 14, 0.92);
  backdrop-filter: blur(16px);
}

.portal-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--paper);
  font-size: 1.08rem;
  font-weight: 760;
  text-decoration: none;
}

.portal-brand img { border-radius: 8px; }
.portal-brand strong { color: var(--amber-light); }

.portal-header-actions,
.language-control {
  display: flex;
  align-items: center;
}

.portal-header-actions { gap: 12px; }

.language-control {
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.language-control button {
  width: 36px;
  height: 30px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--quiet);
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 800;
}

.language-control button[aria-pressed="true"] {
  background: rgba(201, 154, 75, 0.16);
  color: var(--amber-light);
}

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 760;
  text-decoration: none;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.button:hover { transform: translateY(-1px); }
.button svg { width: 17px; height: 17px; }

.button-primary {
  border-color: var(--amber);
  background: var(--amber);
  color: #17120b;
}

.button-primary:hover { background: var(--amber-light); border-color: var(--amber-light); }

.button-ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
}

.button-ghost:hover { border-color: var(--line-strong); color: var(--paper); }
.button-wide { width: 100%; min-height: 50px; }

#portal-main {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
}

.access-shell {
  min-height: calc(100vh - var(--header-height));
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.72fr);
  align-items: center;
  gap: 86px;
  padding: 72px 0 84px;
}

.eyebrow,
.panel-index {
  margin: 0;
  color: var(--amber-light);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.access-copy h1,
.dashboard-intro h1 {
  margin: 14px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 6rem;
  font-weight: 600;
  line-height: 0.98;
}

.access-copy h1 { max-width: 650px; }

.access-lead {
  max-width: 650px;
  margin: 26px 0 0;
  color: var(--muted);
  font-size: 1.06rem;
  line-height: 1.75;
}

.access-proof {
  max-width: 650px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 48px 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  list-style: none;
}

.access-proof li {
  min-width: 0;
  padding: 22px 18px 22px 0;
}

.access-proof li + li {
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.access-proof > li > span {
  display: block;
  margin-bottom: 17px;
  color: var(--amber);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.68rem;
  font-weight: 800;
}

.access-proof strong,
.access-proof small { display: block; }

.access-proof strong { margin-bottom: 7px; font-size: 0.87rem; }

.access-proof small {
  color: var(--quiet);
  font-size: 0.75rem;
  line-height: 1.55;
}

.access-panel {
  position: relative;
  padding: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(18, 22, 22, 0.94);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.36);
}

.access-panel::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 34px;
  width: 80px;
  height: 3px;
  background: var(--amber);
}

.access-panel-heading h2 {
  margin: 14px 0 8px;
  font-size: 1.62rem;
}

.access-panel-heading > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

#access-form { margin-top: 28px; }

#access-form label {
  display: block;
  margin-bottom: 9px;
  color: var(--paper);
  font-size: 0.78rem;
  font-weight: 700;
}

.input-wrap {
  height: 50px;
  display: grid;
  grid-template-columns: 45px minmax(0, 1fr);
  align-items: center;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0b0f0f;
}

.input-wrap:focus-within { border-color: var(--amber); }

.input-wrap svg {
  width: 17px;
  height: 17px;
  margin: auto;
  color: var(--quiet);
}

.input-wrap input {
  min-width: 0;
  height: 100%;
  padding: 0 14px 0 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--paper);
}

.input-wrap input::placeholder { color: #555b57; }

.access-feedback {
  margin-top: 16px;
  padding: 13px 14px;
  border-left: 3px solid var(--green);
  background: rgba(103, 200, 154, 0.08);
  color: #bce5d0;
  font-size: 0.82rem;
  line-height: 1.55;
}

.access-feedback.is-error {
  border-left-color: var(--red);
  background: rgba(217, 107, 102, 0.08);
  color: #efb5b1;
}

.privacy-note {
  display: flex;
  gap: 9px;
  margin: 20px 0 0;
  color: var(--quiet);
  font-size: 0.72rem;
  line-height: 1.5;
}

.privacy-note svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--green); }

.portal-loading {
  min-height: calc(100vh - var(--header-height));
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
}

.loading-mark {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  margin-bottom: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  animation: portal-pulse 1.6s ease-in-out infinite;
}

.portal-loading strong { font-size: 1.2rem; }
.portal-loading p { margin: 8px 0 0; color: var(--muted); }

.dashboard { padding: 58px 0 90px; }

.dashboard-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  padding-bottom: 34px;
  border-bottom: 1px solid var(--line);
}

.dashboard-intro h1 { font-size: 3.6rem; }
.dashboard-intro > div > p:last-child { margin: 15px 0 0; color: var(--muted); }

.account-stamp {
  max-width: 320px;
  padding-left: 18px;
  border-left: 2px solid var(--amber);
}

.account-stamp span,
.account-stamp strong { display: block; }
.account-stamp span { margin-bottom: 5px; color: var(--quiet); font-size: 0.68rem; text-transform: uppercase; }
.account-stamp strong { overflow-wrap: anywhere; font-size: 0.83rem; }

.next-step {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  margin: 34px 0;
  padding: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(201, 154, 75, 0.055);
}

.next-step-marker {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--amber-light);
}

.next-step-marker svg { width: 22px; height: 22px; }
.next-step h2 { margin: 7px 0 4px; font-size: 1.24rem; }
.next-step div > p:last-child { margin: 0; color: var(--muted); font-size: 0.83rem; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
}

.dashboard-panel {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 22, 22, 0.88);
}

.score-history { grid-column: span 7; }
.service-history { grid-column: span 5; }
.documents { grid-column: span 6; }
.payments { grid-column: span 6; }
.devices { grid-column: 1 / -1; }

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 { margin: 7px 0 0; font-size: 1.1rem; }
.panel-heading > svg { width: 21px; height: 21px; color: var(--amber); }

.panel-count {
  min-width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.74rem;
}

.score-stage { min-height: 230px; padding-top: 20px; }

.score-entry {
  display: grid;
  grid-template-columns: minmax(110px, 0.72fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.score-entry:last-child { border-bottom: 0; }
.score-entry-meta strong,
.score-entry-meta small { display: block; }
.score-entry-meta strong { margin-bottom: 5px; font-size: 0.82rem; }
.score-entry-meta small { color: var(--quiet); font-size: 0.7rem; }

.score-track {
  position: relative;
  height: 7px;
  overflow: hidden;
  border-radius: 4px;
  background: #242a27;
}

.score-track::before,
.score-track::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--value);
  border-radius: inherit;
  transform: scaleX(0);
  transform-origin: left;
  animation: score-grow 900ms cubic-bezier(.2,.8,.2,1) forwards;
}

.score-track::before { background: var(--blue); opacity: 0.45; }
.score-track::after { width: var(--after); background: var(--green); animation-delay: 180ms; }

.score-values {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.78rem;
}

.score-values span:first-child { color: var(--blue); }
.score-values span:last-child { color: var(--green); font-weight: 800; }
.score-values svg { width: 14px; height: 14px; color: var(--quiet); }

.record-list { padding-top: 8px; }

.record {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.record:last-child { border-bottom: 0; }
.record-main { min-width: 0; }
.record-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.record-title svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--amber); }
.record-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.83rem; }
.record-meta { margin: 5px 0 0 24px; color: var(--quiet); font-size: 0.7rem; line-height: 1.45; }

.record-action {
  min-width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.record-action:hover { border-color: var(--line-strong); color: var(--amber-light); }
.record-action svg { width: 16px; height: 16px; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.7rem;
}

.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--quiet); }
.status.is-active::before { background: var(--amber); }
.status.is-done::before { background: var(--green); }

.empty-state {
  min-height: 120px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  color: var(--quiet);
  text-align: center;
}

.empty-state svg { width: 24px; height: 24px; }
.empty-state p { max-width: 310px; margin: 0; font-size: 0.78rem; line-height: 1.55; }

.toast {
  position: fixed;
  z-index: 60;
  right: 22px;
  bottom: 22px;
  max-width: min(400px, calc(100vw - 44px));
  padding: 13px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #171b1a;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
  color: var(--paper);
  font-size: 0.82rem;
}

.toast.is-error { border-color: rgba(217, 107, 102, 0.48); color: #efb5b1; }

@keyframes portal-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 154, 75, 0); }
  50% { box-shadow: 0 0 0 12px rgba(201, 154, 75, 0.08); }
}

@keyframes score-grow { to { transform: scaleX(1); } }

@media (max-width: 980px) {
  .access-shell { grid-template-columns: 1fr; gap: 48px; padding-top: 54px; }
  .access-panel { max-width: 620px; }
  .score-history,
  .service-history,
  .documents,
  .payments { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  :root { --header-height: 62px; }
  .portal-header { padding: 0 16px; }
  .portal-brand { font-size: 0.93rem; }
  .portal-brand img { width: 34px; height: 34px; }
  .portal-header .button-ghost span { display: none; }
  .portal-header .button-ghost { width: 38px; min-height: 36px; padding: 0; }
  .language-control button { width: 31px; }
  #portal-main { width: min(100% - 28px, 1180px); }
  .access-shell { min-height: auto; padding: 44px 0 60px; }
  .access-copy h1 { font-size: 3.05rem; }
  .access-lead { font-size: 0.96rem; }
  .access-proof { grid-template-columns: 1fr; margin-top: 34px; }
  .access-proof li { display: grid; grid-template-columns: 32px 1fr; gap: 12px; padding: 16px 0; }
  .access-proof li + li { padding-left: 0; border-top: 1px solid var(--line); border-left: 0; }
  .access-proof > li > span { margin: 2px 0 0; }
  .access-panel { padding: 26px 20px; }
  .access-panel::before { left: 20px; }
  .dashboard { padding: 38px 0 64px; }
  .dashboard-intro { align-items: start; flex-direction: column; }
  .dashboard-intro h1 { font-size: 2.7rem; }
  .account-stamp { width: 100%; max-width: none; }
  .next-step { grid-template-columns: 44px minmax(0, 1fr); gap: 15px; padding: 19px; }
  .next-step-marker { width: 42px; height: 42px; }
  .next-step .button { grid-column: 1 / -1; }
  .dashboard-grid { display: block; }
  .dashboard-panel { margin-top: 14px; padding: 20px 16px; }
  .score-entry { grid-template-columns: 1fr auto; gap: 10px; }
  .score-track { grid-column: 1 / -1; grid-row: 2; }
  .record-meta { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
