
:root {
  --blue: #00268B;
  --blue-dark: #001a63;
  --bg: #F3F6FB;
  --card: #fff;
  --tx: #172033;
  --tx2: #667085;
  --bd: #E2E8F0;
  --tint: #EAF0FF;
  --r: 20px;
  --side: 256px;
  --ff: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--ff);
  font-size: 16px;
  line-height: 1.5;
  color: var(--tx);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

[hidden] { display: none !important; }
button { font-family: inherit; }

/* Estrutura */
.shell {
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  height: 100vh;
  height: 100dvh;
}

.portal.is-loading { overflow: hidden; }

.content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  min-height: 0;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: var(--r);
  padding: 20px 14px;
}

.sidebar__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand__logo {
  height: 36px;
  width: auto;
  max-width: 110px;
  object-fit: contain;
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.brand__text strong {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: .02em;
}

.brand__text span {
  font-size: .64rem;
  font-weight: 600;
  color: var(--tx2);
  letter-spacing: .06em;
}

.sidebar__label {
  margin: 28px 12px 8px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--tx2);
}

.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar ul {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu__item {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--tx2);
  font: 500 .95rem/1.2 var(--ff);
  text-align: left;
  cursor: pointer;
  transition: background-color .18s, color .18s;
}

.menu__item svg { flex: none; }

.menu__item:hover {
  background: var(--bg);
  color: var(--tx);
}

.menu__item.is-active {
  background: var(--tint);
  color: var(--blue);
  font-weight: 600;
}

.menu__item.is-active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--blue);
}

/* Novo no fundo da sidebar */
.sidebar__footer {
  margin-top: auto;
  padding-top: 20px;
}

.sidebar__new {
  width: 100%;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  border: 0;
  border-radius: 14px;
  background: var(--blue);
  color: #fff;
  font: 600 .96rem/1.2 var(--ff);
  cursor: pointer;
  box-shadow: 0 5px 14px rgba(0, 38, 139, .15);
  transition: background .18s, transform .18s, box-shadow .18s;
}

.sidebar__new:hover {
  background: var(--blue-dark);
  box-shadow: 0 7px 18px rgba(0, 38, 139, .22);
}

.sidebar__new:active { transform: scale(.98); }

.sidebar__new svg {
  width: 21px;
  height: 21px;
  flex: none;
}

.sidebar__close { display: none; }

.iconbtn {
  width: 44px;
  height: 44px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--bd);
  border-radius: 12px;
  background: var(--card);
  color: var(--blue);
  cursor: pointer;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(23, 32, 51, .45);
}

/* Conteúdo */
.mobilebar { display: none; }

.pagehead h1 {
  margin: 0;
  font-size: 1.9rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.01em;
}

.pagehead p {
  margin: 4px 0 0;
  color: var(--tx2);
  font-size: .95rem;
}

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: var(--r);
  overflow: hidden;
}

.homeview {
  padding: 28px;
  overflow-y: auto;
}

.homeview h2 {
  margin: 0 0 20px;
  font-size: 1.1rem;
  font-weight: 600;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 150px;
  padding: 18px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 16px;
  color: var(--tx);
  cursor: pointer;
  transition: background-color .2s, color .2s, border-color .2s;
}

.card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: auto;
  border-radius: 12px;
  background: var(--tint);
  color: var(--blue);
  transition: background-color .2s, color .2s;
}

.card__arrow {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--bd);
  border-radius: 50%;
}

.card strong {
  margin-top: 14px;
  font-size: 1.05rem;
  font-weight: 600;
}

.card__desc {
  font-size: .85rem;
  color: var(--tx2);
  transition: color .2s;
}

.card:hover {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.card:hover .card__icon {
  background: rgba(255, 255, 255, .16);
  color: #fff;
}

.card:hover .card__arrow {
  border-color: rgba(255, 255, 255, .5);
}

.card:hover .card__desc { color: rgba(255, 255, 255, .8); }

.viewer {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: var(--card);
}

/* Estados */
.state {
  margin: auto;
  max-width: 460px;
  padding: 32px 24px;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--bd);
  border-radius: 16px;
}

.state strong {
  display: block;
  font-size: 1.05rem;
  font-weight: 600;
}

.state p {
  margin: 8px 0 0;
  color: var(--tx2);
  font-size: .92rem;
}

.state--inline {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  z-index: 2;
  width: calc(100% - 24px);
}

/* Formulários */
.viewer-page { background: var(--card); }

.vwr {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  padding: 22px 24px 16px;
}

.vwr__head { padding: 0 0 14px; }

.vwr__head h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 650;
  color: var(--blue);
  line-height: 1.25;
}

.vwr__head p {
  margin: 2px 0 0;
  color: var(--tx2);
  font-size: .92rem;
}

.vwr__body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}

.vwr__frame {
  width: 100%;
  height: 100%;
  border: 1px solid var(--bd);
  border-radius: 16px;
  background: var(--card);
}

.vwr__hint {
  margin: 10px 2px 0;
  font-size: .78rem;
  color: var(--tx2);
}

.loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--tx2);
  font-size: .92rem;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--tint);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

/* Modal Novo */
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(13, 24, 48, .55);
  backdrop-filter: blur(4px);
}

.modal__panel {
  width: min(100%, 560px);
  max-height: min(82dvh, 720px);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(0, 15, 60, .25);
  animation: modal-in .2s ease both;
}

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--bd);
}

.modal__heading {
  display: flex;
  align-items: flex-start;
  gap: 13px;
}

.modal__heading-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 13px;
  background: var(--tint);
  color: var(--blue);
}

.modal__heading h2 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.35;
  font-weight: 700;
}

.modal__heading p {
  margin: 5px 0 0;
  color: var(--tx2);
  font-size: .86rem;
}

.modal__close {
  width: 38px;
  height: 38px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--bd);
  border-radius: 11px;
  background: #fff;
  color: var(--tx2);
  cursor: pointer;
}

.modal__close:hover {
  background: var(--bg);
  color: var(--blue);
}

.modal__body { padding: 20px 24px 24px; }

.modal__label {
  margin: 0 0 12px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--tx2);
}

.modal__options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.modal__option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--bd);
  border-radius: 14px;
  background: #fff;
  color: var(--tx);
  text-align: left;
  cursor: pointer;
  transition: border-color .18s, background .18s, transform .18s;
}

.modal__option:hover {
  border-color: var(--blue);
  background: #F7F9FF;
  transform: translateY(-1px);
}

.modal__option-icon {
  width: 44px;
  height: 44px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--tint);
  color: var(--blue);
}

.modal__option-copy {
  flex: 1;
  min-width: 0;
}

.modal__option-copy strong {
  display: block;
  font-size: .94rem;
  font-weight: 600;
}

.modal__option-copy span {
  display: block;
  margin-top: 3px;
  font-size: .81rem;
  color: var(--tx2);
}

.modal__option-arrow {
  color: var(--tx2);
  flex: none;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Ecrã de carregamento */
.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(180deg, #001a63 0%, #00268B 50%, #2150C8 100%);
  transition: opacity .5s ease, visibility .5s ease;
}

.splash.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.splash__center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 24px;
  animation: rise .8s ease both;
}

.splash__tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  margin-bottom: 22px;
  padding: 16px;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(0, 16, 70, .35);
}

.splash__tile img {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.splash__tile span {
  position: absolute;
  font-size: 3rem;
  font-weight: 700;
  color: var(--blue);
}

.splash__title {
  font-size: clamp(1.7rem, 6vw, 2.4rem);
  font-weight: 700;
  letter-spacing: .06em;
}

.splash__tag {
  margin-top: 6px;
  font-size: .78rem;
  font-weight: 500;
  letter-spacing: .16em;
  opacity: .9;
}

.splash__waves {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 22vh;
  min-height: 110px;
}

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

/* Responsivo: apenas o menu hambúrguer */
@media (max-height: 700px) {
  .sidebar__footer { padding-top: 12px; }
}

@media (max-width: 1100px) {
  :root { --side: 224px; }
  .pagehead h1 { font-size: 1.6rem; }
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
    height: 100vh;
    height: 100dvh;
  }

  .content { gap: 10px; }

  .mobilebar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    min-height: 48px;
    padding-right: 56px;
  }

  .mobilebar .brand__logo { margin-left: 0 !important; }

  .mobilebar .brand__text strong { font-size: .95rem; }
  .mobilebar .brand__text span { font-size: .58rem; }

  .mobilebar .iconbtn {
    position: absolute !important;
    right: 0 !important;
    top: 50%;
    transform: translateY(-50%);
  }

  .pagehead { display: none; }

  .sidebar {
    position: fixed;
    z-index: 60;
    top: 10px;
    bottom: 10px;
    left: 10px;
    width: min(300px, 84vw);
    box-shadow: 0 20px 50px rgba(23, 32, 51, .3);
    transform: translateX(-115%);
    visibility: hidden;
    transition: transform .25s ease, visibility .25s;
  }

  .sidebar.is-open {
    transform: translateX(0);
    visibility: visible;
  }

  .menu__item.is-active::before { left: -14px; }

  .homeview { padding: 18px; }

  /* Eliminar completamente a navegação inferior */
  .bottomnav { display: none !important; }

  .modal { padding: 14px; }
  .modal__panel { max-height: 88dvh; }
  .modal__head { padding: 20px 18px 16px; }
  .modal__body { padding: 18px; }
}

@media (max-width: 620px) {
  .vwr { padding: 14px 12px 10px; }
  .modal__heading h2 { font-size: 1.08rem; }
  .modal__option { padding: 12px; }
}

@media (max-width: 420px) {
  .brand__text span { font-size: .55rem; }
  .cards { grid-template-columns: 1fr; }
  .card { min-height: 120px; }
}

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

/* Cartões de operações de stock */
.cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}

.card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    width: 100%;
    min-height: 210px;
    padding: 26px;
    text-align: left;
    color: #172033;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 38, 139, 0.12);
}

.card__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    background: #f0f4ff;
    border-radius: 12px;
}

.card__title {
    font-size: 18px;
    font-weight: 700;
    color: #00268B;
}

.card__description {
    font-size: 14px;
    line-height: 1.5;
    color: #64748b;
}

.card__action {
    margin-top: auto;
    font-size: 14px;
    font-weight: 600;
    color: #00268B;
}

.menu__item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.menu__icon {
    flex-shrink: 0;
}

.modal__option {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.modal__option > span:last-child {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

@media (max-width: 640px) {
    .cards {
        grid-template-columns: 1fr;
    }
}


/* =========================================
   SIDEBAR — PROPOSITUS GESTÃO DE STOCK
========================================= */

.sidebar {
    background: #ffffff;
    border-right: 1px solid #e8edf5;
    padding: 24px 16px;
}

/* Área da marca */
.sidebar__top {
    padding: 8px 4px 28px;
    border-bottom: 1px solid #edf0f5;
    margin-bottom: 25px;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.sidebar .brand__text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar .brand__text strong {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #00268B;
}

.sidebar .brand__text span {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: #8290a8;
}

/* Título da navegação */
.sidebar__label {
    padding: 0 12px;
    margin: 0 0 14px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.4px;
    color: #94a3b8;
}

/* Lista de operações */
.sidebar nav ul {
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 0;
    margin: 0;
    list-style: none;
}

/* Botões do menu */
.menu__item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 13px;
    width: 100%;
    min-height: 54px;
    padding: 10px 13px;
    border: 1px solid transparent;
    border-radius: 11px;
    background: transparent;
    color: #526078;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    transition: all 0.2s ease;
}

/* Fundo dos ícones */
.menu__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: #eef3ff;
    color: #00268B;
    transition: all 0.2s ease;
}

.menu__icon svg {
    width: 21px;
    height: 21px;
}

/* Efeito ao passar o rato */
.menu__item:hover {
    background: #f3f6fc;
    color: #00268B;
    border-color: #e4eafe;
}

.menu__item:hover .menu__icon {
    background: #00268B;
    color: #ffffff;
}

.menu__item:hover .menu__icon svg {
    stroke: currentColor;
}

/* Operação seleccionada */
.menu__item.active,
.menu__item[aria-current="page"] {
    background: #edf3ff;
    color: #00268B;
    border-color: #dce6ff;
    font-weight: 700;
}

.menu__item.active::before,
.menu__item[aria-current="page"]::before {
    content: "";
    position: absolute;
    left: -16px;
    top: 10px;
    bottom: 10px;
    width: 4px;
    border-radius: 0 5px 5px 0;
    background: #00268B;
}

.menu__item.active .menu__icon,
.menu__item[aria-current="page"] .menu__icon {
    background: #00268B;
    color: #ffffff;
}

/* Rodapé do Sidebar */
.sidebar__footer {
    margin-top: auto;
    padding-top: 22px;
    border-top: 1px solid #edf0f5;
}

/* Botão Nova Operação */
.sidebar__new {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 12px 15px;
    border: none;
    border-radius: 10px;
    background: #00268B;
    color: #ffffff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 38, 139, 0.15);
    transition: all 0.2s ease;
}

.sidebar__new:hover {
    background: #0037b8;
    transform: translateY(-2px);
    box-shadow: 0 7px 16px rgba(0, 38, 139, 0.22);
}

.sidebar__new:active {
    transform: scale(0.98);
}

.sidebar__new svg {
    flex-shrink: 0;
}

/* Foco acessível */
.menu__item:focus-visible,
.sidebar__new:focus-visible {
    outline: 3px solid rgba(0, 38, 139, 0.25);
    outline-offset: 3px;
}

/* Sidebar em dispositivos móveis */
@media (max-width: 768px) {
    .sidebar {
        box-shadow: 10px 0 35px rgba(0, 0, 0, 0.08);
    }

    .sidebar__top {
        margin-bottom: 20px;
    }
}
