/* Shell 17.2.2 — sobrescreve layout legado; tokens em sbmenu-tokens.css */

html, body { font-family: var(--sb-font, Roboto, "Segoe UI", system-ui, sans-serif); }

.oper-icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; line-height: 0; }
.oper-loading::after {
  content: "";
  display: inline-block;
  width: 1em; height: 1em;
  margin-left: .5em;
  border: 2px solid var(--oper-border);
  border-top-color: var(--oper-primary);
  border-radius: 50%;
  animation: oper-spin .7s linear infinite;
  vertical-align: -0.15em;
}
@keyframes oper-spin { to { transform: rotate(360deg); } }

.oper-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sb-drawer-w, 272px) 1fr;
  transition: grid-template-columns .2s ease;
}
.oper-shell.nav-collapsed { grid-template-columns: var(--sb-drawer-collapsed, 72px) 1fr; }
.oper-drawer-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(11,31,59,.45);
  z-index: 40;
}
.oper-sidebar {
  background: var(--oper-navy);
  color: #fff;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 50;
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
  margin-top: 52px;
  overflow-y: auto;
}
.oper-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 4px 4px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.oper-brand img { width: 112px; height: 34px; object-fit: contain; object-position: left center; }
.oper-brand-mark { display: none; }
.oper-brand-text { display: grid; gap: 1px; min-width: 0; }
.oper-brand-text strong { color: var(--oper-primary); font-size: .78rem; line-height: 1; text-transform: uppercase; letter-spacing: .08em; }
.oper-brand-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: rgba(255,255,255,.62); }
.oper-nav-section {
  padding: 0 14px;
  margin-top: 2px;
  color: rgba(255,255,255,.38);
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.oper-shell.nav-collapsed .oper-brand-text,
.oper-shell.nav-collapsed .oper-nav-section,
.oper-shell.nav-collapsed .oper-nav a > span:not(.oper-nav-badge):not(.oper-icon),
.oper-shell.nav-collapsed .oper-back-to-admin > span:not(.oper-icon),
.oper-shell.nav-collapsed .oper-collapse-btn > span:not(.oper-icon) { display: none; }
.oper-shell.nav-collapsed .oper-brand { justify-content: center; padding-left: 0; padding-right: 0; }
.oper-shell.nav-collapsed .oper-brand-full { display: none; }
.oper-shell.nav-collapsed .oper-brand-mark { display: block; width: 36px; height: 36px; }
.oper-shell.nav-collapsed .oper-nav a,
.oper-shell.nav-collapsed .oper-back-to-admin,
.oper-shell.nav-collapsed .oper-collapse-btn {
  justify-content: center;
  gap: 0;
  padding-left: 0;
  padding-right: 0;
  position: relative;
}
.oper-shell.nav-collapsed .oper-nav-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  margin: 0;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: .62rem;
}
.oper-shell.nav-collapsed .oper-sidebar { padding-left: 8px; padding-right: 8px; }

.oper-nav { display: grid; gap: 4px; flex: 1; grid-template-columns: 1fr !important; align-content: start; grid-auto-rows: min-content; }
.oper-nav a {
  min-height: var(--oper-touch);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border-radius: var(--sb-radius, 8px);
  color: rgba(255,255,255,.88);
  font-weight: 500;
}
.oper-nav a.active, .oper-nav a:hover {
  background: rgba(255,106,0,.92);
  color: #fff;
}
.oper-nav-badge {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  font-size: .7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.oper-nav-badge.pending { background: var(--oper-primary); }
.oper-nav-badge.conflict { background: var(--oper-danger); }

.oper-collapse-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

/* P1 — navegação entre modos: identificação discreta + volta para a Gestão (sem SSO/JWT na URL) */
.oper-back-to-admin {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px dashed rgba(255,255,255,.25);
  color: rgba(255,255,255,.7);
  font-weight: 500;
  font-size: .85rem;
}
.oper-back-to-admin:hover { background: rgba(255,255,255,.06); color: #fff; }
.oper-shell.nav-collapsed .oper-back-to-admin > span:not(.oper-icon) { display: none; }

.oper-main { display: flex; flex-direction: column; min-width: 0; padding-top: 52px; background: var(--oper-bg); }
.oper-appbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 60;
  min-height: 52px;
  background: var(--oper-navy);
  color: #fff;
  border-bottom: 3px solid var(--oper-primary);
  padding: 4px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  box-shadow: var(--sb-shadow);
}
.oper-appbar-title { display: grid; gap: 2px; flex: 1; min-width: 120px; }
.oper-appbar-title strong { font-weight: 600; }
.oper-appbar-title > div { display: flex; align-items: center; gap: 8px; }
.oper-mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(255,106,0,.14);
  border: 1px solid rgba(255,106,0,.5);
  color: #ffb26f;
  font-size: .64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.oper-appbar .oper-muted { color: rgba(255,255,255,.65); font-size: .8rem; }
.oper-icon-btn {
  width: var(--oper-touch);
  height: var(--oper-touch);
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.oper-icon-btn:hover { background: rgba(255,255,255,.1); }
.oper-icon-btn--mobile { display: none; }

.oper-appbar .oper-chip {
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.08);
  color: #fff;
}
.oper-appbar .oper-chip.online { border-color: #4caf50; color: #a5d6a7; background: rgba(76,175,80,.15); }
.oper-appbar .oper-chip.offline { border-color: #ef9a9a; color: #ffcdd2; background: rgba(211,47,47,.2); }
.oper-appbar .oper-chip.sync { border-color: #ffb74d; color: #ffe0b2; background: rgba(237,108,2,.2); }
.oper-appbar .oper-chip.pending { border-color: var(--oper-primary); color: #ffcc80; }
.oper-appbar .oper-chip.conflict { border-color: #ef9a9a; color: #ffcdd2; background: rgba(211,47,47,.25); }

.oper-account { position: relative; }
.oper-account-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0;
  border-radius: 0;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-weight: 500;
}
.oper-account-copy { display: grid; text-align: right; gap: 1px; }
.oper-account-copy strong { font-size: .82rem; line-height: 1.1; font-weight: 600; }
.oper-account-copy small { color: rgba(255,106,0,.9); font-size: .66rem; line-height: 1.1; }
.oper-account-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--oper-primary);
  color: #fff;
  font-size: .82rem;
  font-weight: 700;
}
.oper-account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  background: #fff;
  color: var(--oper-text);
  border-radius: 8px;
  box-shadow: var(--sb-shadow-lg);
  padding: 12px;
  z-index: 60;
  border: 1px solid var(--oper-border);
}

.oper-page-title { margin: 0 0 4px; font-size: 1.45rem; font-weight: 600; color: var(--oper-navy); }
.oper-page-sub { margin: 0 0 16px; color: var(--oper-muted); }
.oper-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--oper-muted);
  border: 1px dashed var(--oper-border);
  border-radius: var(--oper-radius);
  background: var(--oper-surface);
}
.oper-alert.info { background: #eef2f7; border-color: #c5d0dc; color: var(--oper-navy); }
.oper-btn { gap: 8px; }

.oper-update-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 12px 16px;
  background: #fff7ed;
  border-bottom: 1px solid #fdba74;
  color: var(--oper-navy, #0B1F3B);
}
.oper-update-banner strong { display: block; margin-bottom: 2px; }
.oper-update-banner span { font-size: .9rem; color: var(--oper-muted, #5b6b7c); }
.oper-update-banner__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.oper-update-banner--blocking {
  background: #fef2f2;
  border-bottom-color: #fca5a5;
}

.oper-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(11,31,59,.45);
  z-index: 80;
}
.oper-modal {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 24px));
  background: #fff;
  border-radius: var(--sb-radius-lg, 14px);
  box-shadow: var(--sb-shadow-lg);
  padding: 20px;
  z-index: 90;
}
.oper-modal h3 { margin: 0 0 8px; }
.oper-modal p { margin: 0 0 8px; }

.d-none-mobile { display: inline; }

.oper-conflict-card--focus {
  outline: 2px solid #FF6A00;
  box-shadow: 0 0 0 3px rgba(255, 106, 0, 0.25);
}
.oper-conflict-card {
  border: 1px solid #fecaca;
  background: #fff7f7;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}
.oper-conflict-card h4 { margin: 0 0 8px; }

@media (max-width: 900px) {
  .oper-shell,
  .oper-shell.nav-collapsed { grid-template-columns: 1fr; }
  .oper-sidebar {
    position: fixed !important;
    inset: 52px auto 0 0;
    width: min(var(--sb-drawer-w, 272px), 86vw);
    height: calc(100vh - 52px);
    margin-top: 0;
    transform: translateX(-105%);
    transition: transform .2s ease;
    box-shadow: var(--sb-shadow-lg);
    top: 52px !important;
  }
  .oper-shell.drawer-open .oper-sidebar { transform: translateX(0); }
  .oper-shell.drawer-open .oper-drawer-backdrop { display: block; }
  .oper-icon-btn--desktop { display: none; }
  .oper-icon-btn--mobile { display: inline-flex; }
  .oper-collapse-btn { display: none; }
  .oper-nav { grid-template-columns: 1fr !important; }
  .oper-shell.nav-collapsed .oper-brand-text { display: grid; }
  .oper-shell.nav-collapsed .oper-nav-section { display: block; }
  .oper-shell.nav-collapsed .oper-nav a > span:not(.oper-nav-badge):not(.oper-icon) { display: inline; }
  .oper-shell.nav-collapsed .oper-back-to-admin > span:not(.oper-icon) { display: inline; }
  .oper-shell.nav-collapsed .oper-nav a,
  .oper-shell.nav-collapsed .oper-back-to-admin {
    justify-content: flex-start;
    gap: 12px;
    padding: 0 14px;
  }
  .oper-shell.nav-collapsed .oper-nav-badge {
    position: static;
    top: auto;
    right: auto;
    margin-left: auto;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    font-size: .7rem;
  }
  .oper-shell.nav-collapsed .oper-brand-full { display: block; width: 112px; }
  .oper-shell.nav-collapsed .oper-brand-mark { display: none; }
}

@media (max-width: 768px) {
  .d-none-mobile { display: none !important; }
}

@media (max-width: 430px) {
  .oper-modal {
    left: 0; right: 0; top: auto; bottom: 0;
    transform: none;
    width: 100%;
    max-height: min(90vh, 640px);
    overflow: auto;
    border-radius: 16px 16px 0 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }
  .oper-sheet,
  .oper-sheet-wide {
    left: 0; right: 0; top: auto; bottom: 0;
    width: 100%;
    max-height: min(92vh, 720px);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -12px 32px rgba(11, 31, 59, .2);
  }
  .oper-product-pick-list { max-height: 40vh; }
  .oper-appbar { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .oper-appbar-title { min-width: 0; }
  .oper-appbar-title strong {
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .oper-mode-badge { display: none; }
}
