*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bc: #625be1;
  --bc-deep: #463fbe;
  --bc-bright: #8a88d3;
  --bc-hover: #514bc4;
  --bc-soft: rgba(98, 91, 225, 0.1);
  --bc-muted: rgba(138, 136, 211, 0.28);
  --bc-gradient: linear-gradient(135deg, #625be1, #8a88d3);
  --font: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
}

html, body { height: 100%; font-family: var(--font); }

body {
  min-height: 100vh;
  background: #0a1a10 url('../images/login/biochar-login-bg.jpg') center center / cover no-repeat fixed;
  overflow: hidden;
  position: relative;
  animation: bgPan 45s ease-in-out infinite alternate;
}

body::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(6, 16, 10, 0.28) 0%, rgba(6, 16, 10, 0.08) 45%, rgba(6, 16, 10, 0.18) 100%);
}

@keyframes bgPan {
  0% { background-position: 50% 50%; }
  100% { background-position: 48% 52%; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@keyframes flow {
  from { background-position: 0 0; }
  to { background-position: 200% 0; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

.brand-logo {
  position: fixed;
  top: 24px;
  left: clamp(24px, 4.5vw, 56px);
  z-index: 30;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  animation: rise .7s ease both;
  transition: transform .2s ease, box-shadow .2s ease;
}

.brand-logo:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.34);
}

.brand-logo img {
  height: clamp(32px, 4.4vh, 40px);
  width: auto;
  max-width: min(270px, 60vw);
  object-fit: contain;
  display: block;
  filter: none;
}

.login-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 22px 12px;
  cursor: pointer;
  border-radius: 16px 0 0 16px;
  background: #ffffff;
  border: 1px solid #d0d5dd;
  border-right: none;
  box-shadow: -6px 0 24px rgba(0, 0, 0, 0.15);
  transition: opacity .3s, transform .25s, box-shadow .25s;
}

.login-tab:hover {
  box-shadow: -8px 0 32px rgba(98, 91, 225, 0.28);
  transform: translateY(-50%) translateX(-2px);
}

.login-tab.hidden { opacity: 0; pointer-events: none; }

.login-tab svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--bc);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-tab span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 2.4px;
  text-transform: uppercase;
  color: var(--bc);
}

.login-panel {
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  height: 100dvh;
  width: min(440px, 100vw);
  z-index: 40;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(10px, 1.6vh, 22px);
  padding: clamp(36px, 5vh, 56px) clamp(28px, 3vw, 44px) clamp(24px, 3vh, 36px);
  overflow: hidden;
  background: #ffffff;
  border-left: 1px solid #eaecf0;
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.22);
  transform: translateX(100%);
  opacity: 0;
  transition: transform .5s cubic-bezier(.22, 1, .36, 1), opacity .35s ease;
}

.login-panel.open { transform: translateX(0); opacity: 1; }

.login-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--bc-deep), var(--bc), var(--bc-bright), var(--bc));
  background-size: 200% 100%;
  animation: flow 5s linear infinite;
}

.close-btn {
  position: absolute;
  top: 18px;
  left: 16px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #d0d5dd;
  background: #f8f9fa;
  color: #344054;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .2s, transform .2s, border-color .2s;
  z-index: 5;
}

.close-btn:hover {
  background: #eaecf0;
  border-color: var(--bc);
  color: var(--bc);
  transform: rotate(90deg);
}

.close-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
}

.panel-head {
  position: relative;
  z-index: 1;
  margin-bottom: 0;
  text-align: center;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.panel-mark-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto clamp(8px, 1.2vh, 14px);
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.panel-mark {
  width: auto;
  height: clamp(40px, 5.6vh, 56px);
  max-width: min(200px, 68%);
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.12));
}

.panel-head .tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--bc-soft);
  border: 1px solid var(--bc-muted);
  color: var(--bc);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: clamp(6px, 1vh, 12px);
}

.panel-head .tag::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bc);
  box-shadow: 0 0 8px rgba(98, 91, 225, 0.55);
  animation: pulse 1.6s ease-in-out infinite;
}

.panel-head h2 {
  font-size: clamp(1.35rem, 2.4vh, 1.7rem);
  font-weight: 800;
  color: #101828;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.panel-head h2 span { color: var(--bc); }

.panel-head p {
  margin-top: clamp(4px, 0.8vh, 8px);
  font-size: clamp(0.74rem, 1.3vh, 0.86rem);
  color: #667085;
  line-height: 1.4;
}

.form-block { position: relative; z-index: 1; flex-shrink: 0; }

.alert-error,
.alert-success {
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.78rem;
  margin-bottom: 10px;
}

.alert-error {
  background: #fef3f2;
  border: 1px solid #fda29b;
  color: #b42318;
}

.alert-success {
  background: #ecfdf3;
  border: 1px solid #abefc6;
  color: #067647;
}

.field { margin-bottom: clamp(8px, 1.2vh, 14px); }

.field label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #344054;
  margin-bottom: 6px;
}

.field > input,
.field-control input {
  width: 100%;
  height: clamp(40px, 5.2vh, 48px);
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid #d0d5dd;
  background: #ffffff;
  color: #101828;
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s, transform .15s;
}

.field > input::placeholder,
.field-control input::placeholder { color: #98a2b3; }

.field > input:focus,
.field-control input:focus {
  border-color: var(--bc);
  box-shadow: 0 0 0 4px rgba(98, 91, 225, 0.18);
  transform: translateY(-1px);
}

.field-control { position: relative; }

.field-control .toggle-pass {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: #667085;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
}

.field-control .toggle-pass:hover {
  color: var(--bc);
  background: var(--bc-soft);
}

.field-control input[type="password"],
.field-control input[type="text"] { padding-right: 72px; }

.row-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 2px 0 clamp(10px, 1.4vh, 16px);
  font-size: 0.78rem;
  color: #475467;
}

.remember {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.remember input {
  width: 15px;
  height: 15px;
  accent-color: var(--bc);
}

.btn-login {
  width: 100%;
  height: clamp(42px, 5.4vh, 50px);
  border: 0;
  border-radius: 12px;
  background: var(--bc-gradient);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 800;
  font-family: inherit;
  letter-spacing: 0.3px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(98, 91, 225, 0.35);
  position: relative;
  overflow: hidden;
  transition: transform .18s, box-shadow .2s;
}

.btn-login::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 -40%;
  width: 40%;
  background: rgba(255, 255, 255, 0.18);
  transform: skewX(-18deg);
  transition: left .45s;
  left: -40%;
}

.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(98, 91, 225, 0.45);
}

.btn-login:hover::after { left: 130%; }
.btn-login:active { transform: translateY(0); }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: clamp(12px, 1.8vh, 20px) 0 0;
}

.divider i {
  flex: 1;
  height: 1px;
  background: #e4e7ec;
}

.divider span {
  font-size: 0.68rem;
  font-weight: 700;
  color: #667085;
  white-space: nowrap;
}

.cix-wordmark {
  display: inline-block;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--bc);
  text-decoration: none;
}

.cix-wordmark:hover { text-decoration: underline; }

.panel-foot {
  margin-top: 0;
  text-align: center;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.panel-foot .monitor {
  font-size: 0.68rem;
  font-weight: 600;
  color: #667085;
  margin-bottom: clamp(8px, 1.2vh, 14px);
  line-height: 1.45;
}

.panel-foot .cix-logo {
  width: clamp(110px, 16vh, 150px);
  max-width: 64%;
  display: block;
  margin: 0 auto 6px;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.1));
}

.panel-foot .dev {
  font-size: 0.7rem;
  font-weight: 600;
  color: #101828;
  margin-bottom: 3px;
}

.panel-foot .links {
  font-size: 0.62rem;
  color: #475467;
  margin-bottom: 3px;
}

.panel-foot .links a {
  color: var(--bc);
  text-decoration: none;
}

.panel-foot .links a:hover { text-decoration: underline; }

.panel-foot .site a {
  color: #344054;
  text-decoration: none;
  font-size: 0.7rem;
}

.panel-foot .site a:hover { color: var(--bc); }

.site-copyright {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 20;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-size: 0.74rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(4, 14, 10, 0.68);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  border-radius: 999px;
  padding: 6px 18px;
  transition: background .2s, border-color .2s;
}

.site-copyright:hover {
  background: rgba(4, 14, 10, 0.84);
  border-color: rgba(138, 136, 211, 0.55);
}

.site-copyright .cix-wordmark {
  color: #a7a5e2 !important;
  text-shadow: 0 0 10px rgba(98, 91, 225, 0.55);
}

.panel-head,
.form-block,
.panel-foot {
  opacity: 0;
  transform: translateX(22px);
  transition: opacity .4s ease, transform .4s ease;
}

.login-panel.open .panel-head { opacity: 1; transform: none; transition-delay: .18s; }
.login-panel.open .form-block { opacity: 1; transform: none; transition-delay: .28s; }
.login-panel.open .panel-foot { opacity: 1; transform: none; transition-delay: .38s; }

@media (max-width: 480px) {
  .brand-logo { top: 12px; left: 12px; padding: 6px 10px; border-radius: 12px; }
  .brand-logo img { height: 36px; }
  .login-panel { width: 100%; padding: 40px 22px 22px; overflow: hidden; }
  .site-copyright { font-size: 0.62rem; bottom: 10px; max-width: calc(100vw - 24px); white-space: normal; text-align: center; }
}

@media (max-height: 700px) {
  .panel-head p { display: none; }
  .panel-foot .monitor { margin-bottom: 6px; }
}

@media (max-height: 640px) {
  .panel-foot .monitor { display: none; }
  .login-panel { gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}
