:root {
	/* Deep background ramp (very dark, faintly hued toward the brand). */
	--bg-0: #070b16;
	--bg-1: #0d1426;
	--bg-2: #131d38;
	--bg-1-rgb: 13, 20, 38;
	--bg-2-rgb: 19, 29, 56;
	/* Brand accents — `*-rgb` triplets let us vary alpha for glows/rings. */
	--brand: #2563eb;
	--brand-2: #38bdf8;
	--brand-rgb: 37, 99, 235;
	--brand-2-rgb: 56, 189, 248;
	/* Hue rotation that tints the white leaf-spring SVGs to the brand colour. */
	--spring-hue: 176deg;
	--ember: #fb923c;
	--ember-2: #f59e0b;
	--steel: #93a4c4;
	--text: #eef2fb;
	--muted: #93a0bd;
	--card-stroke: rgba(255, 255, 255, .12);
}

/* Per-company palette — set on <body> once a company is picked, so EVERY brand
   accent (glows, focus ring, button, leaf-spring tint and the deep background)
   echoes the selected tenant. Mobrasma (blue) is the :root default. */
body[data-tenant="r10"] {
	--brand: #dc2626;
	--brand-2: #f87171;
	--brand-rgb: 220, 38, 38;
	--brand-2-rgb: 248, 113, 113;
	--spring-hue: 332deg;
	--bg-0: #120709;
	--bg-1: #1c0d12;
	--bg-2: #341524;
	--bg-1-rgb: 28, 13, 18;
	--bg-2-rgb: 52, 21, 36;
}
body[data-tenant="nx"] {
	--brand: #16a34a;
	--brand-2: #34d399;
	--brand-rgb: 22, 163, 74;
	--brand-2-rgb: 52, 211, 153;
	--spring-hue: 96deg;
	--bg-0: #06120c;
	--bg-1: #0b1f16;
	--bg-2: #123626;
	--bg-1-rgb: 11, 31, 22;
	--bg-2-rgb: 18, 54, 38;
}

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

html, body { height: 100%; }

body {
	font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
	color: var(--text);
	background: var(--bg-0);
	overflow: hidden;
	display: grid;
	place-items: center;
	position: relative;
}

/* ── Living industrial background ───────────────────────────────── */

.scene { position: fixed; inset: 0; overflow: hidden; z-index: 0; }

/* Deep steel gradient with slowly drifting forge glow */
.scene::before {
	content: "";
	position: absolute; inset: -20%;
	background:
		radial-gradient(60% 50% at 78% 18%, rgba(var(--brand-rgb), .28), transparent 60%),
		radial-gradient(55% 45% at 12% 88%, rgba(251, 146, 60, .18), transparent 60%),
		linear-gradient(160deg, var(--bg-2), var(--bg-1) 45%, var(--bg-0));
	animation: drift 22s ease-in-out infinite alternate;
}
@keyframes drift {
	from { transform: translate3d(-2%, -1%, 0) scale(1.05); }
	to   { transform: translate3d(2%, 2%, 0) scale(1.12); }
}

/* Faint moving "factory floor" grid — conveyor feel */
.scene::after {
	content: "";
	position: absolute; inset: 0;
	background-image:
		linear-gradient(rgba(147, 164, 196, .06) 1px, transparent 1px),
		linear-gradient(90deg, rgba(147, 164, 196, .06) 1px, transparent 1px);
	background-size: 46px 46px;
	mask-image: radial-gradient(circle at 50% 60%, #000 0%, transparent 75%);
	animation: floor 30s linear infinite;
}
@keyframes floor { from { background-position: 0 0, 0 0; } to { background-position: 0 460px, 460px 0; } }

/* Leaf-spring motifs (ready-made vectors), tinted steel-blue and gently flexing */
.spring {
	position: absolute;
	background-repeat: no-repeat;
	background-position: center;
	background-size: contain;
	filter: invert(1) sepia(.5) saturate(2.6) hue-rotate(var(--spring-hue)) brightness(.96);
	pointer-events: none;
	will-change: transform;
}
.spring-a {
	right: clamp(-160px, 1vw, 70px);
	top: 50%;
	width: 560px; height: 480px;
	background-image: url("/login/parabolic.svg");
	opacity: .22;
	filter: invert(1) sepia(.5) saturate(2.6) hue-rotate(var(--spring-hue)) brightness(.96)
		drop-shadow(0 0 28px rgba(var(--brand-2-rgb), .25));
	animation: flexA 7.5s ease-in-out infinite;
}
@keyframes flexA {
	0%, 100% { transform: translateY(-50%) rotate(-6deg); }
	50%      { transform: translateY(-50%) rotate(-3deg); }
}
.spring-b {
	left: -90px;
	bottom: 5%;
	width: 640px; height: 250px;
	background-image: url("/login/feixe.svg");
	opacity: .13;
	animation: flexB 9.5s ease-in-out infinite;
}
@keyframes flexB {
	0%, 100% { transform: rotate(2.5deg); }
	50%      { transform: rotate(-1.5deg); }
}

/* Forge embers rising from the heat */
.embers { position: absolute; inset: 0; }
.embers i {
	position: absolute; bottom: -12px;
	width: 6px; height: 6px; border-radius: 50%;
	background: radial-gradient(circle, var(--ember-2), var(--ember) 60%, transparent 72%);
	box-shadow: 0 0 10px 2px rgba(251, 146, 60, .55);
	animation: rise linear infinite;
	opacity: 0;
}
@keyframes rise {
	0%   { transform: translateY(0) translateX(0) scale(1); opacity: 0; }
	12%  { opacity: .9; }
	70%  { opacity: .8; }
	100% { transform: translateY(-94vh) translateX(var(--sway, 24px)) scale(.4); opacity: 0; }
}

/* ── Login card ─────────────────────────────────────────────────── */

main {
	position: relative; z-index: 1;
	width: min(404px, 92vw);
	padding: 2.4rem 2.2rem 2rem;
	border-radius: 20px;
	background: linear-gradient(160deg, rgba(255, 255, 255, .10), rgba(255, 255, 255, .035));
	border: 1px solid var(--card-stroke);
	box-shadow:
		0 30px 70px -20px rgba(0, 0, 0, .65),
		inset 0 1px 0 rgba(255, 255, 255, .14);
	backdrop-filter: blur(18px) saturate(140%);
	-webkit-backdrop-filter: blur(18px) saturate(140%);
	animation: cardIn .7s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes cardIn {
	from { opacity: 0; transform: translateY(22px) scale(.985); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

.brand { margin-bottom: 1.5rem; }
.brand .logo { height: 38px; width: auto; display: block; }
.brand .tag { font-size: .74rem; color: var(--muted); margin-top: .6rem; letter-spacing: .2px; }

form { display: flex; flex-direction: column; }
.field { position: relative; margin-top: 1rem; animation: fieldIn .6s ease both; }
.field:nth-of-type(1) { animation-delay: .08s; }
.field:nth-of-type(2) { animation-delay: .16s; }
.field:nth-of-type(3) { animation-delay: .24s; }
@keyframes fieldIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

label {
	display: block; font-size: .72rem; font-weight: 600; letter-spacing: .4px;
	text-transform: uppercase; color: var(--muted); margin-bottom: .4rem;
	transition: color .2s;
}
.combo-button, input {
	width: 100%; padding: .72rem .8rem; font-size: .95rem; color: var(--text);
	background: rgba(7, 11, 22, .55);
	border: 1px solid rgba(147, 164, 196, .22);
	border-radius: 11px;
	transition: border-color .2s, box-shadow .2s, background .2s;
	appearance: none;
}
input::placeholder { color: rgba(147, 164, 196, .55); }
input:focus,
.combo-button:focus-visible,
.combo.is-open .combo-button {
	outline: none;
	border-color: var(--brand-2);
	box-shadow: 0 0 0 3px rgba(var(--brand-2-rgb), .22);
	background: rgba(7, 11, 22, .72);
}
.field:focus-within label { color: var(--brand-2); }

/* ── Custom company combobox (replaces the native <select> so the open
      list matches the card design instead of the OS dropdown) ─────────── */
/* Each .field is position:relative, so the later username/password fields
   create their own stacking contexts and would paint over the open list.
   Lift the tenant field while its combo is open so the dropdown stays on top. */
.field:has(.combo.is-open) { z-index: 10; }
.combo { position: relative; }
.combo-button {
	display: flex; align-items: center; justify-content: space-between; gap: .6rem;
	text-align: left; cursor: pointer; font-family: inherit;
}
.combo-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-value.is-placeholder { color: rgba(147, 164, 196, .55); }
.combo-arrow {
	flex: none; width: 9px; height: 9px; margin-right: 2px;
	border-right: 2px solid var(--steel); border-bottom: 2px solid var(--steel);
	border-radius: 1px;
	transform: translateY(-2px) rotate(45deg);
	transition: transform .2s ease, border-color .2s;
}
.combo.is-open .combo-arrow { transform: translateY(1px) rotate(-135deg); border-color: var(--brand-2); }

.combo-list {
	position: absolute; z-index: 5; top: calc(100% + 7px); left: 0; right: 0;
	max-height: 232px; overflow-y: auto; padding: .35rem;
	list-style: none; margin: 0;
	background: linear-gradient(160deg, rgba(var(--bg-2-rgb), .96), rgba(var(--bg-1-rgb), .96));
	border: 1px solid rgba(147, 164, 196, .22);
	border-radius: 13px;
	box-shadow: 0 22px 48px -18px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .07);
	backdrop-filter: blur(16px) saturate(140%);
	-webkit-backdrop-filter: blur(16px) saturate(140%);
	animation: comboIn .16s ease both;
	scrollbar-width: thin; scrollbar-color: rgba(147, 164, 196, .4) transparent;
}
@keyframes comboIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.combo-list::-webkit-scrollbar { width: 9px; }
.combo-list::-webkit-scrollbar-thumb { background: rgba(147, 164, 196, .3); border-radius: 9px; border: 2px solid transparent; background-clip: content-box; }

.combo-option {
	display: flex; align-items: center; gap: .55rem;
	padding: .6rem .7rem; border-radius: 9px; font-size: .93rem; color: var(--text);
	cursor: pointer; transition: background .14s, color .14s;
}
.combo-option:hover,
.combo-option.is-active {
	background: rgba(var(--brand-2-rgb), .14);
	color: #fff;
}
.combo-option[aria-selected="true"] { font-weight: 600; }
.combo-option .check {
	flex: none; width: 14px; height: 8px; margin-left: auto;
	border-left: 2px solid var(--brand-2); border-bottom: 2px solid var(--brand-2);
	transform: rotate(-45deg); opacity: 0; transition: opacity .14s;
}
.combo-option[aria-selected="true"] .check { opacity: 1; }
.combo-empty { padding: .6rem .7rem; font-size: .88rem; color: var(--muted); }

button[type=submit] {
	position: relative; overflow: hidden;
	margin-top: 1.7rem; padding: .8rem; font-size: .98rem; font-weight: 700; letter-spacing: .3px;
	color: #fff; cursor: pointer;
	border: 0; border-radius: 12px;
	background: linear-gradient(135deg, var(--brand), var(--brand-2));
	box-shadow: 0 12px 26px -10px rgba(var(--brand-rgb), .8);
	transition: transform .15s ease, box-shadow .2s ease, filter .2s;
}
button[type=submit]::after {
	content: ""; position: absolute; inset: 0;
	background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, .35), transparent 70%);
	transform: translateX(-130%); transition: transform .6s;
}
button[type=submit]:hover { transform: translateY(-2px); box-shadow: 0 18px 34px -10px rgba(var(--brand-rgb), .9); filter: saturate(1.1); }
button[type=submit]:hover::after { transform: translateX(130%); }
button[type=submit]:active { transform: translateY(0); }
button[type=submit]:disabled { cursor: wait; filter: grayscale(.2) brightness(.92); }
button[type=submit]:disabled .btn-label { opacity: .55; }
.spinner {
	display: none; width: 17px; height: 17px; margin-right: .55rem;
	border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%;
	animation: spin .7s linear infinite; vertical-align: -3px;
}
button[type=submit]:disabled .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

#error {
	display: none; margin-top: 1.1rem; padding: .65rem .8rem; font-size: .84rem;
	border-radius: 10px; color: #fecaca;
	background: rgba(190, 18, 60, .18); border: 1px solid rgba(248, 113, 113, .4);
}
#error.show { display: block; animation: shake .4s; }
@keyframes shake {
	0%, 100% { transform: translateX(0); }
	20%, 60% { transform: translateX(-6px); }
	40%, 80% { transform: translateX(6px); }
}

footer { margin-top: 1.5rem; text-align: center; font-size: .7rem; color: rgba(147, 164, 196, .65); }

@media (prefers-reduced-motion: reduce) {
	.scene::before, .scene::after, .spring, .embers i,
	main, .field, button[type=submit]::after { animation: none !important; }
}
