/* CodeSphere Admin: design tokens ------------------------------------------ */
:root {
  --ink: #06140d;
  --forest: #0b2e1c;
  --forest-2: #134430;
  --green: #43b02a;
  --green-text: #1f6e13;
  --red: #c9261f;
  --red-bg: #fdeceb;
  --paper: #f3f6f1;
  --card: #ffffff;
  --line: #d8e0d6;
  --line-strong: #b9c6b6;
  --text: #0e1a13;
  --muted: #566559;
  --radius: 12px;
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Instrument Sans", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
h1, h2, p { margin: 0; }
a { color: var(--green-text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--ink); }
button { font: inherit; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; border-radius: 6px; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }

/* Auth layout --------------------------------------------------------------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(360px, 5fr) 6fr; }

.brand-panel {
  background: var(--ink);
  color: #e9f1ea;
  padding: 40px 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  border-right: 1px solid var(--forest-2);
  position: relative;
  overflow: hidden;
}
.logo { display: inline-flex; align-items: center; gap: 12px; font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; letter-spacing: -0.01em; color: #fff; }
.logo svg { flex: none; }
.logo small { font-family: var(--font-body); font-weight: 500; font-size: 0.8rem; color: #9db3a2; border-left: 1px solid var(--forest-2); padding-left: 12px; }

.rails { width: 100%; max-width: 520px; height: auto; align-self: center; }
.rails .lane { fill: none; stroke: var(--forest-2); stroke-width: 2; }
.rails .lane-live { fill: none; stroke: var(--green); stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.4s cubic-bezier(.6, 0, .2, 1) .2s forwards; }
.rails .lane-live.l2 { animation-delay: .45s; }
.rails .lane-live.l3 { animation-delay: .7s; }
.rails .ring { fill: none; stroke: var(--forest-2); stroke-width: 2; }
.rails .ring-core { fill: var(--green); opacity: 0; animation: pop .5s ease 1.7s forwards; }
.rails .ring-halo { fill: none; stroke: var(--green); stroke-width: 1.5; opacity: 0; transform-origin: 380px 180px; animation: halo 2.4s ease-out 1.8s 2; }
.rails text { font-family: var(--font-body); font-size: 15px; font-weight: 600; fill: #c6d6c9; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.4); transform-origin: 380px 180px; } to { opacity: 1; transform: scale(1); transform-origin: 380px 180px; } }
@keyframes halo { 0% { opacity: .7; transform: scale(.7); } 100% { opacity: 0; transform: scale(1.7); } }

.brand-copy h2 { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.7rem, 2.6vw, 2.4rem); line-height: 1.12; letter-spacing: -0.02em; color: #fff; max-width: 14em; text-wrap: balance; }
.brand-copy p { margin-top: 14px; color: #9db3a2; max-width: 34em; }

.auth-main { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px 24px 24px; gap: 24px; }
.card { width: 100%; max-width: 440px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 40px; }
.card.enter { animation: card-in .22s ease-out; }
@keyframes card-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card h1 { font-family: var(--font-display); font-weight: 700; font-size: 1.7rem; line-height: 1.15; letter-spacing: -0.02em; text-wrap: balance; }
.card h1:focus { outline: none; }
.lede { margin-top: 10px; color: var(--muted); }
.lede strong { color: var(--text); font-weight: 600; }

form { margin-top: 28px; display: grid; gap: 18px; }

/* Fields -------------------------------------------------------------------- */
.field label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
.control { position: relative; }
.control > .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; pointer-events: none; }
.control input {
  width: 100%; height: 50px; padding: 0 14px 0 44px;
  font: inherit; color: var(--text); background: #fff;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.control input::placeholder { color: #8b998f; }
.control input:hover { border-color: #8fa08c; }
.control input:focus { outline: none; border-color: var(--green-text); box-shadow: 0 0 0 4px rgba(67, 176, 42, .22); }
.control input[aria-invalid="true"] { border-color: var(--red); box-shadow: 0 0 0 4px rgba(201, 38, 31, .1); }
.control.has-toggle input { padding-right: 48px; }
.toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; display: grid; place-items: center; background: none; border: 0; color: var(--muted); border-radius: 8px; cursor: pointer; }
.toggle:hover { color: var(--text); background: var(--paper); }
.field-msg { min-height: 0; margin-top: 6px; font-size: 0.85rem; color: var(--red); }
.field-msg:empty { display: none; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 0.9rem; }

.form-error { display: none; gap: 10px; align-items: flex-start; background: var(--red-bg); color: #8f1b16; border: 1px solid #f3c3c0; border-radius: var(--radius); padding: 12px 14px; font-size: 0.9rem; }
.form-error.show { display: flex; }
.form-error svg { flex: none; margin-top: 2px; }

/* Buttons ------------------------------------------------------------------- */
.btn {
  position: relative; height: 50px; width: 100%; border: 0; border-radius: var(--radius);
  background: var(--forest); color: #fff; font-weight: 600; font-size: 1rem; cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--forest-2); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn[aria-busy="true"] { color: transparent; pointer-events: none; }
.btn[aria-busy="true"]::after { content: ""; position: absolute; inset: 0; margin: auto; width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-link { background: none; border: 0; padding: 0; color: var(--green-text); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.btn-link:disabled { color: var(--muted); text-decoration: none; cursor: default; }
.back { display: inline-flex; align-items: center; gap: 6px; margin-top: 22px; font-size: 0.9rem; font-weight: 500; text-decoration: none; color: var(--muted); }
.back:hover { color: var(--text); }

.secure-note { display: flex; align-items: center; gap: 8px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; }

/* OTP ----------------------------------------------------------------------- */
.otp { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.otp input {
  width: 100%; height: 58px; text-align: center; padding: 0;
  font-family: var(--font-display); font-weight: 700; font-size: 1.6rem; color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.otp input:focus { outline: none; border-color: var(--green-text); box-shadow: 0 0 0 4px rgba(67, 176, 42, .22); }
.otp input.filled { border-color: var(--forest); }
.otp.invalid input { border-color: var(--red); }
.otp.shake { animation: shake .36s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.resend { display: flex; justify-content: center; gap: 6px; color: var(--muted); font-size: 0.9rem; }

/* Password strength --------------------------------------------------------- */
.meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.meter span { height: 4px; border-radius: 4px; background: var(--line); transition: background .2s; }
.meter[data-level="1"] span:nth-child(-n+1) { background: var(--red); }
.meter[data-level="2"] span:nth-child(-n+2) { background: #d98a12; }
.meter[data-level="3"] span:nth-child(-n+3) { background: #7aa81f; }
.meter[data-level="4"] span:nth-child(-n+4) { background: var(--green); }
.rules { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 0.82rem; color: var(--muted); }
.rules li { display: flex; align-items: center; gap: 6px; }
.rules li::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line-strong); flex: none; }
.rules li.ok { color: var(--green-text); }
.rules li.ok::before { border-color: var(--green); background: var(--green) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M3.5 7.2l2.2 2.2 4.8-4.9' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat; }

.done { text-align: left; }
.done .badge { width: 52px; height: 52px; border-radius: 50%; background: rgba(67, 176, 42, .16); color: var(--green-text); display: grid; place-items: center; margin-bottom: 20px; }
.done .btn { margin-top: 28px; }

.auth-foot { font-size: 0.82rem; color: var(--muted); text-align: center; }

/* Signed-in placeholder ----------------------------------------------------- */
.shell-top { display: flex; justify-content: space-between; align-items: center; padding: 16px 28px; background: var(--ink); color: #fff; }
.shell-body { padding: 48px 28px; max-width: 760px; margin: 0 auto; }
.shell-body h1 { font-family: var(--font-display); font-size: 1.8rem; letter-spacing: -0.02em; }
.shell-body p { margin-top: 10px; color: var(--muted); }
.btn-ghost { width: auto; height: 40px; padding: 0 18px; background: transparent; border: 1px solid var(--forest-2); }
.btn-ghost:hover { background: var(--forest); }

/* Responsive ---------------------------------------------------------------- */
@media (max-width: 960px) {
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .brand-panel { padding: 20px 24px; border-right: 0; border-bottom: 1px solid var(--forest-2); }
  .rails, .brand-copy { display: none; }
  .auth-main { padding-top: 28px; }
}
@media (max-width: 480px) {
  .card { padding: 28px 22px; border-radius: 14px; }
  .otp { gap: 6px; }
  .otp input { height: 52px; font-size: 1.35rem; }
  .rules { grid-template-columns: 1fr; }
  .logo small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .rails .lane-live { stroke-dashoffset: 0; }
  .rails .ring-core { opacity: 1; }
}
