:root {
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f6f8;
  color: #17202a;
  --ink: #17202a;
  --muted: #667386;
  --panel: #ffffff;
  --line: #d7dee7;
  --line-strong: #aab6c4;
  --blue: #2e5f93;
  --blue-dark: #254f7e;
  --green: #2f735f;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(244, 246, 248, 0.96)),
    #f4f6f8;
}

button,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

.auth-screen {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  isolation: isolate;
}

.auth-panel {
  position: relative;
  z-index: 2;
  width: min(430px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 22px 54px rgba(23, 32, 42, 0.11);
}

.container-yard {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: 0.58;
}

.container-yard::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 45%;
  background:
    linear-gradient(180deg, rgba(244, 246, 248, 0), rgba(215, 222, 231, 0.42)),
    repeating-linear-gradient(90deg, rgba(106, 120, 138, 0.1) 0 1px, transparent 1px 64px);
}

.container-field {
  position: absolute;
  left: 50%;
  bottom: clamp(18px, 4.8vh, 56px);
  width: min(1120px, calc(100vw + 180px));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(7, minmax(72px, 1fr));
  gap: 8px;
  align-items: end;
}

.stacked-container {
  --delay: 0s;
  height: clamp(24px, 3vw, 34px);
  position: relative;
  display: block;
  overflow: hidden;
  border: 1px solid rgba(23, 32, 42, 0.14);
  border-radius: 4px;
  background: #657386;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 7px 14px rgba(23, 32, 42, 0.06);
  opacity: 0;
  transform: translateY(22px);
  animation: containerPlaced 24s ease-in-out infinite;
  animation-delay: var(--delay);
}

.stacked-container::before {
  content: "";
  position: absolute;
  inset: 5px 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  border-right: 1px solid rgba(0, 0, 0, 0.12);
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.15) 0 1px, transparent 1px 10px);
}

.stacked-container:nth-child(3n + 1) { background: #5e6d7d; }
.stacked-container:nth-child(3n + 2) { background: #3f668f; }
.stacked-container:nth-child(3n + 3) { background: #53766e; }
.stacked-container:nth-child(1) { --delay: 0.2s; }
.stacked-container:nth-child(2) { --delay: 0.45s; }
.stacked-container:nth-child(3) { --delay: 0.7s; }
.stacked-container:nth-child(4) { --delay: 0.95s; }
.stacked-container:nth-child(5) { --delay: 1.2s; }
.stacked-container:nth-child(6) { --delay: 1.45s; }
.stacked-container:nth-child(7) { --delay: 1.7s; }
.stacked-container:nth-child(8) { --delay: 2.0s; }
.stacked-container:nth-child(9) { --delay: 2.25s; }
.stacked-container:nth-child(10) { --delay: 2.5s; }
.stacked-container:nth-child(11) { --delay: 2.75s; }
.stacked-container:nth-child(12) { --delay: 3.0s; }
.stacked-container:nth-child(13) { --delay: 3.25s; }
.stacked-container:nth-child(14) { --delay: 3.5s; }
.stacked-container:nth-child(15) { --delay: 3.8s; }
.stacked-container:nth-child(16) { --delay: 4.05s; }
.stacked-container:nth-child(17) { --delay: 4.3s; }
.stacked-container:nth-child(18) { --delay: 4.55s; }
.stacked-container:nth-child(19) { --delay: 4.8s; }
.stacked-container:nth-child(20) { --delay: 5.05s; }
.stacked-container:nth-child(21) { --delay: 5.3s; }
.stacked-container:nth-child(22) { --delay: 5.6s; }
.stacked-container:nth-child(23) { --delay: 5.85s; }
.stacked-container:nth-child(24) { --delay: 6.1s; }
.stacked-container:nth-child(25) { --delay: 6.35s; }
.stacked-container:nth-child(26) { --delay: 6.6s; }
.stacked-container:nth-child(27) { --delay: 6.85s; }
.stacked-container:nth-child(28) { --delay: 7.1s; }
.stacked-container:nth-child(29) { --delay: 7.4s; }
.stacked-container:nth-child(30) { --delay: 7.65s; }
.stacked-container:nth-child(31) { --delay: 7.9s; }
.stacked-container:nth-child(32) { --delay: 8.15s; }
.stacked-container:nth-child(33) { --delay: 8.4s; }
.stacked-container:nth-child(34) { --delay: 8.65s; }
.stacked-container:nth-child(35) { --delay: 8.9s; }

.crane-runway {
  position: absolute;
  left: 0;
  right: 0;
  bottom: clamp(120px, 18vh, 190px);
  height: 100px;
}

.yard-crane {
  position: absolute;
  left: -190px;
  bottom: 0;
  width: 178px;
  height: 96px;
  animation: craneDrive 8.8s linear infinite;
}

.crane-base,
.crane-cab,
.crane-boom,
.crane-cable,
.crane-load,
.crane-wheel {
  position: absolute;
  display: block;
}

.crane-base {
  left: 36px;
  bottom: 18px;
  width: 78px;
  height: 22px;
  border: 1px solid rgba(23, 32, 42, 0.16);
  border-radius: 5px;
  background: #566779;
}

.crane-cab {
  left: 18px;
  bottom: 31px;
  width: 42px;
  height: 26px;
  border: 1px solid rgba(23, 32, 42, 0.14);
  border-radius: 6px 6px 3px 3px;
  background: #3f668f;
}

.crane-cab::after {
  content: "";
  position: absolute;
  right: 7px;
  top: 6px;
  width: 14px;
  height: 8px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.46);
}

.crane-wheel {
  bottom: 11px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #273443;
}

.wheel-left { left: 47px; }
.wheel-right { left: 92px; }

.crane-boom {
  left: 54px;
  bottom: 52px;
  width: 118px;
  height: 4px;
  border-radius: 999px;
  background: #566779;
  transform: rotate(-18deg);
  transform-origin: left center;
}

.crane-cable {
  left: 138px;
  bottom: 45px;
  width: 1px;
  height: 42px;
  background: rgba(23, 32, 42, 0.28);
  animation: cableLower 8.8s ease-in-out infinite;
}

.crane-load {
  left: 104px;
  bottom: 31px;
  width: 70px;
  height: 25px;
  border: 1px solid rgba(23, 32, 42, 0.14);
  border-radius: 4px;
  background: #53766e;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.13);
  animation: loadDrop 8.8s ease-in-out infinite;
}

.crane-load::before {
  content: "";
  position: absolute;
  inset: 5px 7px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.15) 0 1px, transparent 1px 9px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #1f344d;
  color: #fff;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.workspace-label {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: 26px;
  line-height: 1.12;
}

h2 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 18px;
}

p {
  margin: 0;
}

.stack {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
  color: #344256;
  font-size: 13px;
  font-weight: 700;
}

.field input {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid #c7d0dc;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.field input:hover {
  border-color: var(--line-strong);
}

.field input:focus {
  outline: 0;
  border-color: rgba(46, 95, 147, 0.82);
  box-shadow: 0 0 0 4px rgba(46, 95, 147, 0.12);
}

.row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.gap-sm {
  gap: 10px;
}

.auth-actions {
  margin-top: 4px;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
  transition: box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

.button svg {
  width: 18px;
  height: 18px;
}

.button:disabled {
  opacity: 0.74;
  cursor: wait;
}

.button.primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 12px 24px rgba(46, 95, 147, 0.18);
}

.button.primary:hover:not(:disabled) {
  background: var(--blue-dark);
  box-shadow: 0 14px 30px rgba(46, 95, 147, 0.22);
}

.button.subtle {
  background: #f2f5f8;
  color: #223047;
  border-color: var(--line);
}

.settings-section {
  display: grid;
  gap: 14px;
}

.section-heading {
  display: grid;
  gap: 4px;
  color: #475569;
}

.mfa-enroll-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.mfa-qr-code {
  width: 180px;
  height: 180px;
  justify-self: center;
  image-rendering: pixelated;
}

.auth-status {
  min-height: 0;
  margin-top: 16px;
  color: var(--danger);
  font-size: 13px;
}

.auth-status:empty {
  display: none;
}

.auth-status.is-error {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid rgba(180, 35, 24, 0.18);
  border-radius: 8px;
  background: #fff7f5;
}

.auth-status.is-loading {
  min-height: 92px;
  display: grid;
  align-items: center;
  color: var(--green);
}

.login-loading {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(47, 115, 95, 0.16);
  border-radius: 8px;
  background: #f6faf8;
}

.login-loading-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(47, 115, 95, 0.12);
  position: relative;
}

.login-loading-mark::before {
  content: "";
  width: 15px;
  height: 8px;
  border-left: 2px solid var(--green);
  border-bottom: 2px solid var(--green);
  transform: rotate(-45deg) translate(1px, -1px);
}

.login-loading-mark::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 1px solid rgba(47, 115, 95, 0.16);
  border-radius: inherit;
  animation: successPulse 1.7s ease-in-out infinite;
}

.login-loading-copy {
  display: grid;
  gap: 3px;
  color: #24453c;
}

.login-loading-copy strong {
  color: #20352f;
  font-size: 13px;
}

.login-loading-copy span {
  color: #637083;
  font-size: 12px;
}

.data-loader {
  grid-column: 1 / -1;
  display: block;
  width: 100%;
}

.data-loader-track {
  position: relative;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e3e9f0;
}

.data-loader-track::before {
  content: "";
  position: absolute;
  inset: 0 78% 0 -18%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgba(47, 115, 95, 0.88), transparent);
  animation: loaderSweep 1.7s ease-in-out infinite;
}

.data-loader-nodes {
  display: none;
}

.toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  z-index: 50;
}

.toast {
  padding: 12px 14px;
  border-radius: 8px;
  background: #17202a;
  color: #fff;
  box-shadow: 0 16px 36px rgba(23, 32, 42, 0.2);
}

.toast strong {
  display: block;
  margin-bottom: 3px;
}

@keyframes loaderSweep {
  0% { transform: translateX(0); }
  100% { transform: translateX(380%); }
}

@keyframes successPulse {
  0%, 100% {
    transform: scale(0.9);
    opacity: 0.35;
  }
  50% {
    transform: scale(1.08);
    opacity: 0.75;
  }
}

@keyframes containerPlaced {
  0%, 8% {
    opacity: 0;
    transform: translateY(22px);
  }
  12%, 86% {
    opacity: 0.72;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(0);
  }
}

@keyframes craneDrive {
  0% { transform: translateX(0); }
  48% { transform: translateX(calc(100vw + 210px)); }
  62% { transform: translateX(calc(100vw + 210px)); }
  100% { transform: translateX(0); }
}

@keyframes cableLower {
  0%, 34%, 70%, 100% { height: 42px; }
  48%, 58% { height: 62px; }
}

@keyframes loadDrop {
  0%, 45% {
    transform: translateY(0);
    opacity: 0.78;
  }
  55%, 64% {
    transform: translateY(20px);
    opacity: 0.18;
  }
  72%, 100% {
    transform: translateY(0);
    opacity: 0.78;
  }
}

@media (max-width: 560px) {
  .auth-screen {
    padding: 16px;
  }

  .auth-panel {
    padding: 22px;
  }

  .container-yard {
    opacity: 0.42;
  }

  .container-field {
    grid-template-columns: repeat(5, minmax(58px, 1fr));
    width: calc(100vw + 110px);
    gap: 6px;
  }

  .crane-runway {
    bottom: 104px;
  }

  h1 {
    font-size: 23px;
  }

  .button,
  .auth-actions {
    width: 100%;
  }
}

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