:root {
  --ink: #09243f;
  --muted: #657488;
  --line: #d8e1ea;
  --panel: rgba(255, 255, 255, 0.9);
  --blue: #2274b8;
  --green: #2f8f72;
  --amber: #b8781f;
  --wine: #8b4161;
  --danger: #b83333;
  --shadow: 0 24px 70px rgba(8, 30, 55, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(135deg, rgba(245, 248, 252, 0.96), rgba(230, 237, 244, 0.96)),
    repeating-linear-gradient(90deg, rgba(9, 36, 63, 0.05) 0 1px, transparent 1px 72px),
    repeating-linear-gradient(0deg, rgba(9, 36, 63, 0.04) 0 1px, transparent 1px 72px);
}

a { color: inherit; }

.topbar {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 26px 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  color: var(--ink);
  text-decoration: none;
}

.brand strong {
  display: block;
  font-size: 19px;
}

.brand small {
  display: block;
  color: var(--muted);
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--ink);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 9px;
}

.brand-mark i {
  border-radius: 5px;
  background: #ffffff;
}

.brand-mark i:nth-child(1) { grid-row: span 2; background: #4da3d9; }
.brand-mark i:nth-child(2) { background: #f0b44d; }
.brand-mark i:nth-child(3) { grid-row: span 2; background: #67b99a; }

nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

nav a,
.button,
button {
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  font: 700 15px "Segoe UI", Arial, sans-serif;
  text-decoration: none;
}

nav a {
  background: rgba(9, 36, 63, 0.08);
  color: var(--ink);
}

.button.muted {
  background: #e7edf4;
  color: var(--ink);
}

.page {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.section-title {
  margin: 34px 0 24px;
}

.section-title.with-action {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

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

h1 {
  margin: 0;
  font-size: clamp(32px, 4vw, 52px);
  line-height: 1.04;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 18px;
  font-size: 22px;
}

.messages {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.message {
  border-radius: 8px;
  padding: 13px 16px;
  background: #eef6ee;
  color: #235f3d;
  font-weight: 700;
}

.message.error {
  background: #fff0f0;
  color: var(--danger);
}

.login-wrap {
  min-height: calc(100vh - 160px);
  display: grid;
  place-items: center;
}

.login-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card {
  width: min(460px, 100%);
  padding: 34px;
  display: grid;
  gap: 18px;
}

.login-card h1 {
  font-size: 38px;
}

/* Portal login institucional */
.portal-login-page {
  overflow-x: hidden;
  background: #eef5ff;
}

.portal-login-page .topbar { display: none; }

.portal-login-page .page {
  width: 100%;
  margin: 0;
  padding: 0;
}

.portal-login-page .messages {
  position: fixed;
  z-index: 20;
  top: 24px;
  left: 50%;
  width: min(540px, calc(100% - 32px));
  margin: 0;
  transform: translateX(-50%);
}

.portal-login-shell {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 60%) minmax(500px, 40%);
  background: linear-gradient(135deg, #eff6ff 0%, #ffffff 72%);
}

.portal-login-photo {
  position: absolute;
  inset: 0 38% 0 0;
  background:
    linear-gradient(130deg, rgba(0, 65, 180, .68), rgba(0, 127, 255, .18)),
    url("/portal/static/portal-fachada-ionlab-hero-v3.png?v=3") left center / cover no-repeat;
  filter: saturate(1.08) contrast(1.04);
}

.portal-login-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0, 42, 125, .2), transparent 62%);
}

.portal-login-accent {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  transform: skewX(-38deg);
  transform-origin: center;
}

.portal-login-accent-one {
  inset: -14% 38% -15% 54%;
  border-right: 2px solid #0b66f2;
  background: linear-gradient(90deg, rgba(0, 105, 255, .92), rgba(0, 114, 248, .12));
}

.portal-login-accent-two {
  width: 130px;
  height: 45%;
  right: -82px;
  bottom: -9%;
  background: linear-gradient(180deg, rgba(0, 101, 235, .13), rgba(0, 101, 235, .02));
}

.portal-login-panel {
  position: relative;
  z-index: 3;
  grid-column: 2;
  display: grid;
  place-items: center;
  padding: 36px clamp(28px, 4vw, 76px) 36px 20px;
  transform: translate(-8.25vw, 22px);
}

.portal-login-card {
  width: min(480px, 100%);
  padding: 48px 40px 48px 54px;
  border: 1px solid rgba(255, 255, 255, .88);
  border-radius: 22px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 28px 80px rgba(0, 57, 135, .18);
  backdrop-filter: blur(12px);
}

.portal-login-logo {
  position: relative;
  overflow: hidden;
  width: min(270px, 88%);
  aspect-ratio: 2472 / 611;
  margin: 0 0 24px;
}
.portal-login-logo img {
  position: absolute;
  top: -35.35%;
  left: -4.37%;
  width: 110.24%;
  max-width: none;
  height: auto;
}

.portal-login-heading { margin-bottom: 23px; }
.portal-login-heading h1 {
  margin: 0 0 8px;
  color: #082a68;
  font-size: clamp(34px, 2.6vw, 40px);
  line-height: 1.08;
}
.portal-login-heading p {
  margin: 0;
  color: #7590c4;
  font-size: 17px;
}

.portal-login-field {
  display: grid;
  gap: 8px;
  margin-top: 15px;
  color: #082a68;
  font-size: 16px;
  font-weight: 800;
}

.portal-input-wrap { position: relative; display: block; }
.portal-input-wrap > svg {
  position: absolute;
  z-index: 2;
  left: 18px;
  top: 50%;
  width: 25px;
  height: 25px;
  transform: translateY(-50%);
  fill: none;
  stroke: #0a3d98;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.portal-input-wrap input {
  min-height: 56px;
  padding: 12px 54px 12px 58px;
  border: 1px solid #abc9f5;
  border-radius: 10px;
  background: #f8fbff;
  color: #092d6c;
  font-size: 17px;
  box-shadow: inset 0 1px 4px rgba(22, 76, 160, .04);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.portal-input-wrap input::placeholder { color: #86a1d2; }
.portal-input-wrap input:focus {
  outline: none;
  border-color: #0878f9;
  box-shadow: 0 0 0 4px rgba(8, 120, 249, .12);
}

.portal-password-toggle {
  position: absolute;
  z-index: 3;
  right: 9px;
  top: 50%;
  min-height: 40px;
  width: 42px;
  padding: 0;
  transform: translateY(-50%);
  background: transparent;
  color: #0a3d98;
}
.portal-password-toggle svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.portal-remember {
  display: flex;
  align-items: center;
  gap: 11px;
  width: fit-content;
  margin: 16px 0;
  color: #173b7b;
  font-size: 17px;
  font-weight: 600;
}
.portal-remember input {
  appearance: none;
  width: 25px;
  min-height: 25px;
  margin: 0;
  border: 1px solid #7caef2;
  border-radius: 5px;
  background: #fff;
}
.portal-remember input:checked {
  border-color: #0878f9;
  background: #0878f9;
  box-shadow: inset 0 0 0 5px #0878f9;
}
.portal-remember input:checked::after {
  content: "✓";
  display: grid;
  place-items: center;
  height: 23px;
  color: #fff;
  font-weight: 900;
}

.portal-login-submit {
  width: 100%;
  min-height: 58px;
  gap: 13px;
  border-radius: 10px;
  background: linear-gradient(100deg, #0796ff 0%, #0752dd 100%);
  box-shadow: 0 12px 28px rgba(5, 87, 224, .22);
  font-size: 18px;
}
.portal-login-submit:hover { filter: brightness(1.04); }
.portal-login-submit svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 960px) {
  .portal-login-shell {
    grid-template-columns: 1fr;
    padding: 32px;
  }
  .portal-login-photo { inset: 0; }
  .portal-login-photo::after { background: rgba(0, 40, 105, .38); }
  .portal-login-accent-one { display: none; }
  .portal-login-panel { grid-column: 1; padding: 0; transform: none; }
  .portal-login-card { width: min(540px, 100%); }
}

@media (max-width: 560px) {
  .portal-login-shell { padding: 18px; align-items: center; }
  .portal-login-card { padding: 30px 24px; border-radius: 17px; }
  .portal-login-logo {
    width: min(292px, 88%);
    margin-bottom: 22px;
  }
  .portal-login-heading h1 { font-size: 31px; }
  .portal-login-heading p { font-size: 16px; }
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid #b9c7d5;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: 500 16px "Segoe UI", Arial, sans-serif;
  padding: 9px 12px;
}

.modules {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.module-card {
  min-height: 260px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
  display: grid;
  align-content: space-between;
  gap: 20px;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.module-card.active:hover {
  transform: translateY(-4px);
  border-color: rgba(34, 116, 184, 0.42);
}

.module-card.locked {
  opacity: 0.58;
  cursor: default;
}

.module-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 28px;
  line-height: 1.08;
}

.module-card small {
  display: block;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}

.module-card b {
  width: fit-content;
  padding: 10px 15px;
  border-radius: 8px;
  background: #eef5fb;
  color: var(--blue);
  font-size: 14px;
}

.module-card.locked b {
  background: #f1f3f5;
  color: #7a8694;
}

.module-icon {
  width: 62px;
  height: 62px;
  border-radius: 16px;
  display: block;
  position: relative;
}

.module-icon::before,
.module-icon::after {
  content: "";
  position: absolute;
  border-radius: 4px;
}

.logistica .module-icon { background: rgba(34, 116, 184, 0.14); }
.logistica .module-icon::before { width: 36px; height: 24px; left: 13px; top: 16px; background: var(--blue); }
.logistica .module-icon::after { width: 42px; height: 5px; left: 10px; bottom: 15px; background: #7aaed3; box-shadow: 7px 8px 0 -1px var(--ink), 25px 8px 0 -1px var(--ink); }

.comercial .module-icon { background: rgba(47, 143, 114, 0.14); }
.comercial .module-icon::before { width: 34px; height: 28px; left: 14px; top: 18px; border: 5px solid var(--green); border-top-width: 9px; }
.comercial .module-icon::after { width: 22px; height: 5px; left: 20px; top: 28px; background: var(--green); }

.crm .module-icon { background: rgba(47, 143, 114, 0.14); }
.crm .module-icon::before { width: 34px; height: 34px; left: 14px; top: 14px; border: 5px solid var(--green); }
.crm .module-icon::after { width: 24px; height: 5px; left: 19px; top: 25px; background: var(--green); box-shadow: 0 10px 0 var(--green); }

.licitacao .module-icon { background: rgba(184, 120, 31, 0.15); }
.licitacao .module-icon::before { width: 34px; height: 10px; left: 14px; top: 18px; background: var(--amber); box-shadow: 0 13px 0 var(--amber), 0 26px 0 var(--amber); }
.licitacao .module-icon::after { width: 22px; height: 46px; right: 11px; top: 8px; border-left: 4px solid var(--ink); }

.financeiro .module-icon { background: rgba(139, 65, 97, 0.15); }
.financeiro .module-icon::before { width: 34px; height: 34px; left: 14px; top: 14px; border: 5px solid var(--wine); }
.financeiro .module-icon::after { width: 26px; height: 5px; left: 18px; top: 29px; background: var(--wine); box-shadow: 0 10px 0 var(--wine); }

.panel {
  padding: 24px;
}

.form-shell.narrow {
  width: min(560px, 100%);
  margin: 0 auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.form-grid .checks,
.form-grid .permissions,
.form-grid .actions {
  grid-column: 1 / -1;
}

.checks {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.checks label,
.permission-grid label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checks input,
.permission-grid input {
  width: 20px;
  min-height: 20px;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.permission-grid label {
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
}

.permission-grid strong,
.permission-grid small {
  display: block;
}

.permission-grid small {
  color: var(--muted);
  margin-top: 2px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
}

.user-table th,
.user-table td {
  border-bottom: 1px solid var(--line);
  padding: 14px 10px;
  text-align: left;
}

.user-table th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.user-table tr:last-child td {
  border-bottom: 0;
}

.workspace-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 18px 0;
}

.workspace-head h1 {
  font-size: clamp(30px, 4vw, 44px);
}

.module-frame-shell {
  height: calc(100vh - 170px);
  min-height: 620px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.module-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #ffffff;
}

@media (max-width: 960px) {
  .modules,
  .form-grid,
  .permission-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .topbar,
  .section-title.with-action {
    align-items: flex-start;
    flex-direction: column;
  }

  .modules,
  .form-grid,
  .permission-grid {
    grid-template-columns: 1fr;
  }

  .module-card {
    min-height: 190px;
  }

  .workspace-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .module-frame-shell {
    height: calc(100vh - 210px);
    min-height: 560px;
  }
}
