:root {
  color-scheme: light;
  --navy-950: #08111f;
  --navy-900: #0f1b2d;
  --navy-800: #17263b;
  --navy-700: #253750;
  --blue: #2563eb;
  --blue-hover: #1d4ed8;
  --blue-soft: #eff6ff;
  --white: #ffffff;
  --background: #f4f7fb;
  --surface: #ffffff;
  --text: #172033;
  --text-muted: #667085;
  --border: #dce3ed;
  --danger: #b42318;
  --danger-background: #fef3f2;
  --success: #067647;
  --shadow: 0 24px 70px rgba(15, 27, 45, 0.13);
  --radius-large: 24px;
  --radius-medium: 16px;
  --radius-small: 10px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--background);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--background);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

[hidden] {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

/* Login */

.auth-layout {
  display: grid;
  grid-template-columns: minmax(360px, 46%) 1fr;
  min-height: 100vh;
}

.brand-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: clamp(40px, 6vw, 90px);
  color: var(--white);
  background:
    radial-gradient(
      circle at 20% 15%,
      rgba(37, 99, 235, 0.45),
      transparent 34%
    ),
    radial-gradient(
      circle at 90% 85%,
      rgba(20, 184, 166, 0.2),
      transparent 32%
    ),
    linear-gradient(145deg, var(--navy-950), var(--navy-800));
}

.brand-panel::after {
  position: absolute;
  right: -120px;
  bottom: -120px;
  width: 420px;
  height: 420px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 50%;
  box-shadow:
    0 0 0 70px rgba(255, 255, 255, 0.025),
    0 0 0 140px rgba(255, 255, 255, 0.018);
  content: "";
}

.brand-panel > * {
  position: relative;
  z-index: 1;
}

.brand-mark {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 18px;
  color: var(--white);
  background: linear-gradient(145deg, #3b82f6, #1d4ed8);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.22);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.06em;
}

.brand-panel h1 {
  max-width: 580px;
  margin: 10px 0 18px;
  font-size: clamp(46px, 6vw, 82px);
  line-height: 0.96;
  letter-spacing: -0.055em;
}

.brand-description {
  max-width: 560px;
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: clamp(17px, 1.7vw, 21px);
}

.eyebrow {
  margin: 0;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand-panel .eyebrow {
  color: #93c5fd;
}

.login-panel {
  display: grid;
  min-height: 100vh;
  padding: 32px;
  place-items: center;
  background:
    linear-gradient(rgba(255, 255, 255, 0.9), rgba(244, 247, 251, 0.95)),
    radial-gradient(circle at 80% 15%, #dbeafe, transparent 40%);
}

.login-card {
  width: min(100%, 460px);
  padding: 44px;
  border: 1px solid rgba(220, 227, 237, 0.85);
  border-radius: var(--radius-large);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.mobile-brand {
  display: none;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
  color: var(--navy-900);
  font-size: 18px;
  font-weight: 800;
}

.mobile-brand .brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 21px;
}

.login-card h2 {
  margin: 8px 0 10px;
  color: var(--navy-900);
  font-size: clamp(30px, 4vw, 39px);
  line-height: 1.12;
  letter-spacing: -0.035em;
}

.subtitle {
  margin: 0 0 30px;
  color: var(--text-muted);
}

.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  margin-bottom: 8px;
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

.field input {
  width: 100%;
  height: 52px;
  padding: 0 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  outline: none;
  color: var(--text);
  background: var(--white);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.field input::placeholder {
  color: #98a2b3;
}

.field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 82px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 12px;
  padding: 7px 5px;
  border: 0;
  transform: translateY(-50%);
  color: var(--blue);
  background: transparent;
  font-size: 13px;
  font-weight: 800;
}

.password-toggle:focus-visible {
  border-radius: 6px;
  outline: 3px solid rgba(37, 99, 235, 0.2);
}

.form-message {
  margin: 4px 0 18px;
  padding: 12px 14px;
  border: 1px solid #fecdca;
  border-radius: var(--radius-small);
  color: var(--danger);
  background: var(--danger-background);
  font-size: 14px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-small);
  font-weight: 800;
  transition:
    transform 150ms ease,
    background-color 150ms ease,
    box-shadow 150ms ease;
}

.primary-button {
  width: 100%;
  min-height: 52px;
  gap: 10px;
  border: 0;
  color: var(--white);
  background: var(--blue);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.22);
}

.primary-button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--blue-hover);
  box-shadow: 0 15px 28px rgba(37, 99, 235, 0.28);
}

.spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.primary-button.loading .spinner {
  display: block;
}

.primary-button.loading .button-label {
  opacity: 0.82;
}

.security-note {
  margin: 22px 0 0;
  color: #98a2b3;
  font-size: 12px;
  text-align: center;
}

/* Dashboard */

.dashboard {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  padding: 26px 18px;
  color: var(--white);
  background: var(--navy-950);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px 32px;
  font-size: 18px;
  font-weight: 800;
}

.brand-mark-small {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  font-size: 20px;
}

.nav-item {
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.nav-item:hover,
.nav-item.active {
  color: var(--white);
  background: rgba(37, 99, 235, 0.22);
}

.sidebar-footer {
  margin-top: auto;
  padding: 18px 12px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer p {
  overflow: hidden;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#sidebar-user-name {
  font-size: 14px;
  font-weight: 800;
}

#sidebar-user-role {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  text-transform: capitalize;
}

.dashboard-content {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 96px;
  padding: 22px clamp(24px, 4vw, 54px);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
}

.topbar h2 {
  margin: 4px 0 0;
  color: var(--navy-900);
  font-size: 27px;
  letter-spacing: -0.025em;
}

.secondary-button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--white);
}

.secondary-button:hover {
  border-color: #b9c5d4;
  background: #f8fafc;
}

.dashboard-main {
  padding: clamp(24px, 4vw, 54px);
}

.welcome-card {
  position: relative;
  overflow: hidden;
  padding: clamp(28px, 5vw, 52px);
  border-radius: var(--radius-large);
  color: var(--white);
  background:
    radial-gradient(
      circle at 92% 20%,
      rgba(59, 130, 246, 0.42),
      transparent 32%
    ),
    linear-gradient(135deg, var(--navy-900), var(--navy-700));
  box-shadow: 0 20px 45px rgba(15, 27, 45, 0.15);
}

.welcome-card::after {
  position: absolute;
  top: -75px;
  right: -50px;
  width: 230px;
  height: 230px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  content: "";
}

.welcome-card .eyebrow {
  color: #93c5fd;
}

.welcome-card h3 {
  margin: 8px 0 12px;
  font-size: clamp(31px, 5vw, 47px);
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.welcome-card p:last-child {
  max-width: 670px;
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.summary-card {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-medium);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(15, 27, 45, 0.055);
}

.summary-card strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--navy-900);
  font-size: 17px;
}

.summary-label {
  display: block;
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.status-online {
  color: var(--success) !important;
}

/* Avvio */

.startup-loader {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  background: var(--navy-950);
  transition:
    opacity 220ms ease,
    visibility 220ms ease;
}

.startup-loader.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.loader-logo {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border-radius: 18px;
  color: var(--white);
  background: var(--blue);
  font-size: 30px;
  font-weight: 800;
}

.loader-ring {
  width: 28px;
  height: 28px;
  margin-top: 24px;
  border: 3px solid rgba(255, 255, 255, 0.16);
  border-top-color: #60a5fa;
  border-radius: 50%;
  animation: spin 750ms linear infinite;
}

.startup-loader p {
  margin: 14px 0 0;
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive */

@media (max-width: 900px) {
  .auth-layout {
    grid-template-columns: 1fr;
  }

  .brand-panel {
    display: none;
  }

  .login-panel {
    padding: 22px;
  }

  .mobile-brand {
    display: flex;
  }

  .dashboard {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px 20px;
  }

  .sidebar-brand {
    padding: 0;
  }

  .sidebar nav,
  .sidebar-footer {
    display: none;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .login-panel {
    align-items: start;
    padding: 18px;
  }

  .login-card {
    margin-top: 18px;
    padding: 28px 22px;
    border-radius: 18px;
  }

  .topbar {
    min-height: 82px;
    padding: 18px 20px;
  }

  .topbar h2 {
    font-size: 23px;
  }

  .dashboard-main {
    padding: 20px;
  }

  .welcome-card,
  .summary-card {
    border-radius: 16px;
  }

  .welcome-card {
    padding: 28px 23px;
  }
}

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