:root {
  --background: #08111f;
  --background-soft: #0d192a;
  --surface: #111f32;
  --surface-soft: #16263c;
  --surface-light: #f5f7fb;

  --primary: #2f80ed;
  --primary-hover: #1f6fd6;
  --primary-soft: rgba(47, 128, 237, 0.14);

  --text: #eaf1fb;
  --text-soft: #9fb0c7;
  --text-dark: #152238;
  --text-dark-soft: #607089;

  --border: rgba(255, 255, 255, 0.1);
  --border-light: #dfe6ef;

  --danger: #d64545;
  --danger-soft: rgba(214, 69, 69, 0.12);

  --shadow:
    0 18px 50px rgba(0, 0, 0, 0.28);

  --radius-small: 10px;
  --radius-medium: 16px;
  --radius-large: 24px;

  --sidebar-width: 270px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;

  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  color: var(--text);
  background: var(--background);

  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.eyebrow {
  margin: 0 0 10px;

  color: #69a7f3;

  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 78px;
  height: 42px;
  padding: 0 14px;

  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;

  color: #ffffff;
  background:
    linear-gradient(
      135deg,
      rgba(47, 128, 237, 0.34),
      rgba(47, 128, 237, 0.08)
    );

  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-height: 46px;
  padding: 0 22px;

  border: 0;
  border-radius: var(--radius-small);

  font-weight: 750;

  transition:
    background-color 160ms ease,
    color 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
  transform: none;
}

.button-primary {
  color: #ffffff;
  background: var(--primary);
}

.button-primary:hover {
  background: var(--primary-hover);
}

.button-secondary {
  color: var(--text-dark);
  background: #ffffff;
  border: 1px solid var(--border-light);
}

.button-secondary:hover {
  background: #edf2f8;
}

.alert {
  padding: 13px 15px;

  border-radius: var(--radius-small);

  font-size: 0.91rem;
  line-height: 1.45;
}

.alert-error {
  color: #9f2727;
  background: #fff0f0;
  border: 1px solid #f1caca;
}

/* =========================================================
   LOGIN
   ========================================================= */

.login-page {
  overflow-x: hidden;
}

.login-layout {
  display: grid;
  grid-template-columns:
    minmax(420px, 1.1fr)
    minmax(420px, 0.9fr);

  min-height: 100vh;
}

.login-brand {
  position: relative;

  display: flex;
  flex-direction: column;
  justify-content: space-between;

  min-height: 100vh;
  padding: 58px 64px 44px;

  overflow: hidden;

  background:
    radial-gradient(
      circle at 18% 18%,
      rgba(47, 128, 237, 0.34),
      transparent 34%
    ),
    radial-gradient(
      circle at 82% 72%,
      rgba(31, 111, 214, 0.19),
      transparent 36%
    ),
    linear-gradient(
      145deg,
      #08111f 0%,
      #0c1a2d 56%,
      #10233d 100%
    );
}

.login-brand::before {
  content: "";

  position: absolute;
  inset: 0;

  pointer-events: none;

  background-image:
    linear-gradient(
      rgba(255, 255, 255, 0.025) 1px,
      transparent 1px
    ),
    linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.025) 1px,
      transparent 1px
    );

  background-size: 42px 42px;
  mask-image:
    linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.85),
      transparent
    );
}

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

.login-brand-content {
  max-width: 670px;
  margin: auto 0;
  padding: 60px 0;
}

.login-brand-content h1 {
  max-width: 620px;
  margin: 0;

  font-size: clamp(3rem, 5.5vw, 5.7rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.login-description {
  max-width: 590px;
  margin: 30px 0 0;

  color: var(--text-soft);

  font-size: clamp(1rem, 1.4vw, 1.24rem);
  line-height: 1.7;
}

.login-brand-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;

  padding-top: 24px;

  color: var(--text-soft);

  border-top: 1px solid var(--border);

  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;

  min-height: 100vh;
  padding: 48px;

  color: var(--text-dark);
  background:
    linear-gradient(
      180deg,
      #f8fafc,
      #eef3f8
    );
}

.login-card {
  width: 100%;
  max-width: 470px;
  padding: 44px;

  border: 1px solid rgba(21, 34, 56, 0.08);
  border-radius: var(--radius-large);

  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.login-card-header {
  margin-bottom: 28px;
}

.login-mobile-brand {
  display: none;

  margin-bottom: 28px;

  color: var(--primary);

  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.login-card-header h2 {
  margin: 0;

  font-size: 2rem;
  line-height: 1.15;
  letter-spacing: -0.035em;
}

.login-card-header > p:last-child {
  margin: 14px 0 0;

  color: var(--text-dark-soft);

  line-height: 1.65;
}

.login-form {
  display: grid;
  gap: 20px;

  margin-top: 24px;
}

.form-field {
  display: grid;
  gap: 8px;
}

.form-field label {
  color: var(--text-dark);

  font-size: 0.9rem;
  font-weight: 750;
}

.form-field input {
  width: 100%;
  min-height: 50px;
  padding: 0 15px;

  color: var(--text-dark);
  background: #ffffff;

  border: 1px solid #ccd6e2;
  border-radius: var(--radius-small);

  outline: none;

  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.form-field input:focus {
  border-color: var(--primary);

  box-shadow:
    0 0 0 4px var(--primary-soft);
}

.login-security-note {
  margin: 24px 0 0;

  color: var(--text-dark-soft);

  font-size: 0.8rem;
  line-height: 1.55;
  text-align: center;
}

/* =========================================================
   PORTAL
   ========================================================= */

.portal-page {
  overflow: hidden;

  color: var(--text-dark);
  background: #eef3f8;
}

.portal-shell {
  display: grid;
  grid-template-columns:
    var(--sidebar-width)
    minmax(0, 1fr);

  height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;

  min-height: 100vh;
  padding: 26px 18px;

  color: var(--text);

  background:
    radial-gradient(
      circle at 15% 10%,
      rgba(47, 128, 237, 0.22),
      transparent 31%
    ),
    linear-gradient(
      180deg,
      #08111f,
      #0d1c30
    );

  border-right: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 13px;

  padding: 0 8px 28px;

  border-bottom: 1px solid var(--border);
}

.sidebar-header > div:last-child {
  display: grid;
  gap: 2px;
}

.sidebar-header strong {
  font-size: 0.96rem;
}

.sidebar-header span {
  color: var(--text-soft);

  font-size: 0.82rem;
}

.sidebar-navigation {
  display: grid;
  gap: 8px;

  margin-top: 26px;
}

.navigation-item {
  display: flex;
  align-items: center;
  gap: 12px;

  width: 100%;
  min-height: 50px;
  padding: 0 14px;

  color: var(--text-soft);
  background: transparent;

  border: 1px solid transparent;
  border-radius: 11px;

  font-size: 0.88rem;
  font-weight: 700;
  text-align: left;

  transition:
    color 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease;
}

.navigation-item:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.055);
}

.navigation-item.active {
  color: #ffffff;

  background:
    linear-gradient(
      135deg,
      rgba(47, 128, 237, 0.28),
      rgba(47, 128, 237, 0.11)
    );

  border-color: rgba(91, 161, 246, 0.32);
}

.navigation-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 26px;
  height: 26px;

  color: #78b1f5;

  border-radius: 8px;

  font-size: 1rem;
}

.sidebar-footer {
  margin-top: auto;
  padding: 22px 9px 4px;

  color: var(--text-soft);

  border-top: 1px solid var(--border);
}

.sidebar-footer p {
  margin: 0 0 5px;

  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-footer small {
  font-size: 0.78rem;
}

.portal-content {
  display: flex;
  flex-direction: column;

  min-width: 0;
  height: 100vh;
  padding: 24px;

  overflow: hidden;
}

.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;

  flex: 0 0 auto;

  padding: 4px 3px 20px;
}

.portal-header h1 {
  margin: 0;

  color: var(--text-dark);

  font-size: clamp(1.7rem, 2.5vw, 2.35rem);
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.portal-header > div:first-child > p:last-child {
  margin: 9px 0 0;

  color: var(--text-dark-soft);

  font-size: 0.92rem;
}

.portal-user-area {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-information {
  display: grid;
  gap: 2px;

  text-align: right;
}

.user-information span {
  color: var(--text-dark-soft);

  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.user-information strong {
  color: var(--text-dark);

  font-size: 0.9rem;
}

.dashboard-container {
  position: relative;

  flex: 1 1 auto;
  min-height: 0;

  overflow: hidden;

  border: 1px solid #d8e0ea;
  border-radius: var(--radius-medium);

  background: #ffffff;

  box-shadow:
    0 12px 30px rgba(17, 31, 50, 0.08);
}

#metabase-dashboard-wrapper {
  display: block;

  width: 100%;
  height: 100%;

  overflow: auto;
  background: #081a27;
}

#metabase-dashboard-wrapper metabase-dashboard {
  display: block;

  width: 100%;
  min-height: 100%;
}

.dashboard-loading {
  position: absolute;
  inset: 0;
  z-index: 2;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;

  color: var(--text-dark-soft);
  background: #ffffff;
}

.dashboard-loading.hidden {
  display: none;
}

.loading-spinner {
  width: 38px;
  height: 38px;

  border: 4px solid #dce6f2;
  border-top-color: var(--primary);
  border-radius: 50%;

  animation: spin 0.8s linear infinite;
}

.dashboard-loading p {
  margin: 0;

  font-size: 0.88rem;
  font-weight: 700;
}

#portal-alert {
  flex: 0 0 auto;
  margin-bottom: 14px;
}

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

/* =========================================================
   RESPONSIVIDADE
   ========================================================= */

@media (max-width: 1050px) {
  :root {
    --sidebar-width: 225px;
  }

  .login-layout {
    grid-template-columns:
      minmax(360px, 0.95fr)
      minmax(400px, 1.05fr);
  }

  .login-brand {
    padding:
      44px
      42px
      36px;
  }

  .login-panel {
    padding: 34px;
  }

  .portal-content {
    padding: 18px;
  }
}

@media (max-width: 820px) {
  .login-layout {
    display: block;
  }

  .login-brand {
    display: none;
  }

  .login-panel {
    min-height: 100vh;
    padding: 22px;
  }

  .login-card {
    max-width: 520px;
    padding: 32px 26px;
  }

  .login-mobile-brand {
    display: block;
  }

  .portal-page {
    overflow: auto;
  }

  .portal-shell {
    display: block;
    height: auto;
  }

  .sidebar {
    position: static;

    min-height: auto;
    padding: 14px 16px;
  }

  .sidebar-header {
    padding: 0 0 14px;
  }

  .sidebar-navigation {
    display: flex;
    gap: 8px;

    margin-top: 14px;

    overflow-x: auto;
  }

  .navigation-item {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
  }

  .sidebar-footer {
    display: none;
  }

  .portal-content {
    height: auto;
    min-height: calc(100vh - 150px);
    padding: 16px;
  }

  .portal-header {
    align-items: flex-start;
  }

  .dashboard-container {
    min-height: 720px;
  }
}

@media (max-width: 600px) {
  .portal-header {
    display: grid;
  }

  .portal-user-area {
    width: 100%;
    justify-content: space-between;
  }

  .user-information {
    text-align: left;
  }

  .portal-header h1 {
    font-size: 1.65rem;
  }

  .portal-header > div:first-child > p:last-child {
    line-height: 1.5;
  }

  .navigation-icon {
    display: none;
  }
}