/* ============================================
   OMNI SYSTEM — Clean Luxury SaaS
   ============================================ */

:root{
  --bg-main:#F6F4EF;
  --bg-card:#FFFFFF;
  --bg-hover:#F1EEE8;
  --bg-input:#FFFFFF;

  --text-primary:#111318;
  --text-secondary:#5F6470;
  --text-tertiary:#858A95;

  --border-light:rgba(17,19,24,.10);
  --border-medium:rgba(17,19,24,.18);

  --gold-primary:#C88A45;
  --gold-soft:#E1B477;
  --gold-hover:#B77735;

  --shadow: 0 8px 24px rgba(0,0,0,.08);

  --radius-12:12px;
  --radius-16:16px;

  /* max() (não soma) com env(titlebar-area-height) — quando o PWA roda com os botões de
     fechar/minimizar do Windows sobrepostos (window-controls-overlay), essa variável entrega a
     altura da faixa reservada pra eles; empurra a topbar inteira pra baixo dessa faixa, então
     nada (avatar, sino, nome) fica escondido atrás dos botões — funciona mesmo num PWA já
     instalado antigo, sem precisar reinstalar (é 0 em qualquer navegador/tela normal). */
  --safe-top: max(env(safe-area-inset-top, 0px), env(titlebar-area-height, 0px));
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --topbar-base-h:72px;
  --topbar-h: calc(var(--topbar-base-h) + var(--safe-top));
}

*{ box-sizing:border-box; }
html,body{ height:100%; overflow-x:hidden; }
body{
  margin:0;
  font-family:Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color:var(--text-primary);
  background:var(--bg-main);
  padding-top: var(--topbar-h);
  padding-bottom: var(--safe-bottom);
  text-rendering:optimizeLegibility;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

main.app{ padding:18px 16px 40px; }
section.page{ max-width:1200px; margin:0 auto; }
.wrap{ max-width:1200px; margin:0 auto; padding:18px 16px 40px; }

.topbar{
  position:fixed; top:0; left:0; right:0;
  height:var(--topbar-h);
  padding: calc(var(--safe-top) + 8px) 16px 8px;
  background:rgba(246,244,239,.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom:1px solid rgba(0,0,0,.06);
  display:flex;
  align-items:center;
  z-index:9999;
}

.topbar-left,
.topbar-right{
  flex:1;
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
}
.topbar-right{ justify-content:flex-end; }

.topbar-center{
  flex:2;
  display:flex;
  justify-content:center;
  min-width:0;
}

.topbar-logo-link{
  display:flex;
  align-items:center;
  text-decoration:none;
}
.topbar-logo{
  height:26px;
  width:auto;
  opacity:.58;
  transition: opacity .18s ease, transform .18s ease;
  user-select:none;
}
.topbar-logo:hover{
  opacity:.92;
  transform:scale(1.03);
}

.topnav{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:nowrap;
  max-width:100%;
}

.topnav-link{
  position:relative;
  text-decoration:none;
  color:var(--text-secondary);
  padding:10px 12px;
  border-radius: var(--radius-12);
  font-weight:600;
  font-size:14px;
  white-space:nowrap;
}
.topnav-link:hover{ background:rgba(255,255,255,.55); color:var(--text-primary); }
.topnav-link.active{ background:rgba(255,255,255,.75); color:var(--text-primary); border:1px solid rgba(0,0,0,.06); }

.topnav-dd{
  position:relative;
  white-space:nowrap;
  padding-bottom:10px;
}
.topnav-dd-btn{
  position:relative;
  appearance:none;
  border:1px solid transparent;
  background:transparent;
  color:var(--text-secondary);
  padding:10px 12px;
  border-radius: var(--radius-12);
  cursor:pointer;
  font-weight:600;
  font-size:14px;
  white-space:nowrap;
}
.topnav-dd:hover .topnav-dd-btn{ background:rgba(255,255,255,.55); color:var(--text-primary); }
.topnav-dd.active .topnav-dd-btn,
.topnav-dd.open .topnav-dd-btn{
  background:rgba(255,255,255,.75);
  border:1px solid rgba(0,0,0,.06);
  color:var(--text-primary);
}

.topnav-dd-menu{
  position:absolute;
  left:0;
  top:100%;
  margin-top:8px;
  min-width:220px;
  background:rgba(255,255,255,.92);
  border:1px solid rgba(0,0,0,.08);
  border-radius:14px;
  box-shadow: var(--shadow);
  padding:10px;
  display:none;
  z-index:10000;
}

.topnav-dd:hover .topnav-dd-menu,
.topnav-dd.open .topnav-dd-menu{ display:block; }

.topnav-dd::after{
  content:"";
  position:absolute;
  left:0; right:0;
  top:100%;
  height:10px;
}

.topnav-dd-menu a{
  display:block;
  text-decoration:none;
  color:var(--text-primary);
  padding:10px 10px;
  border-radius:12px;
  font-weight:600;
  font-size:13px;
}
.topnav-dd-menu a:hover{ background:rgba(198,168,117,.14); }

.dd-title{
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.8px;
  color:var(--text-tertiary);
  padding:6px 10px 4px;
  font-weight:800;
}

.caret{ opacity:.7; margin-left:6px; }

.btn-icon{
  width:38px; height:38px;
  border-radius:12px;
  display:grid; place-items:center;
  text-decoration:none;
  background:rgba(255,255,255,.65);
  border:1px solid rgba(0,0,0,.08);
  color:var(--text-primary);
  font-weight:900;
}
.btn-icon:hover{ filter:brightness(.98); }

.user-menu{ position:relative; }
.user-button{
  border:1px solid rgba(0,0,0,.08);
  background:rgba(255,255,255,.65);
  padding:8px 10px;
  border-radius:14px;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:10px;
  font-weight:700;
}
.user-avatar{
  width:30px; height:30px;
  border-radius:12px;
  background:rgba(198,168,117,.22);
  display:grid; place-items:center;
  font-weight:900;
}
.user-name-top{ font-size:13px; color:var(--text-primary); }

.user-dropdown{
  position:absolute;
  right:0;
  top:52px;
  width:220px;
  background:rgba(255,255,255,.92);
  border:1px solid rgba(0,0,0,.08);
  border-radius:14px;
  box-shadow: var(--shadow);
  padding:10px;
  display:none;
  z-index:10000;
}
.user-dropdown.active{ display:block; }

.dropdown-item{
  display:block;
  text-decoration:none;
  padding:10px 10px;
  border-radius:12px;
  color:var(--text-primary);
  font-weight:700;
  font-size:13px;
}
.dropdown-item:hover{ background:rgba(0,0,0,.04); }
.dropdown-divider{ height:1px; background:rgba(0,0,0,.06); margin:8px 8px; }
.dropdown-item-danger{ color:#9A2E2E; }
.dropdown-item-danger:hover{ background:rgba(201,122,122,.14); }

.nav-short{ display:none; font-weight:900; letter-spacing:.4px; }
.nav-full{ display:inline; }

@media (max-width: 860px){
  .topbar{
    padding: calc(var(--safe-top) + 6px) 10px 6px;
  }

  .topbar-left{ flex:0; margin-right:6px; }
  .topbar-logo{ height:22px; opacity:.50; }
  .topbar-center{ flex:1; justify-content:flex-start; }
  .topbar-right{ flex:0; }

  .topnav{
    gap:6px;
    overflow-x:auto;
    overflow-y:hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width:none;
    max-width:100%;
  }
  .topnav::-webkit-scrollbar{ display:none; }

  .nav-full{ display:none; }
  .nav-short{ display:inline; }

  .topnav-link,
  .topnav-dd-btn{
    padding:10px 10px;
    min-width:44px;
    text-align:center;
  }

  .user-name-top{ display:none; }
}

.card{
  border-radius: var(--radius-16);
  padding:14px;
  background: rgba(255,255,255,.55);
  border:1px solid rgba(0,0,0,.08);
}

.input, select.input{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(0,0,0,.10);
  background:rgba(255,255,255,.75);
  outline:none;
}
.input:focus{
  border-color: rgba(0,0,0,.22);
  box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}

.lbl{
  display:block;
  font-weight:800;
  font-size:12px;
  margin:0 0 6px;
  color:var(--text-secondary);
}

.btn{
  padding:10px 14px;
  border-radius:12px;
  border:1px solid rgba(0,0,0,.10);
  background:rgba(255,255,255,.65);
  cursor:pointer;
  font-weight:800;
}
.btn:hover{ filter:brightness(.98); }
.btn-primary{
  background:rgba(0,0,0,.88);
  color:#fff;
  border-color:rgba(0,0,0,.88);
}
.btn-primary:hover{ filter:brightness(1.02); }
.btn-sm{ padding:7px 10px; border-radius:10px; font-size:12px; font-weight:900; }

.table{
  width:100%;
  border-collapse:collapse;
  overflow:hidden;
  border-radius:16px;
}
.table th{
  text-align:left;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.8px;
  color:var(--text-tertiary);
  padding:10px;
  border-bottom:1px solid rgba(0,0,0,.06);
}
.table td{
  padding:10px;
  border-bottom:1px solid rgba(0,0,0,.06);
}
.table tr:hover td{ background:rgba(198,168,117,.10); }

.badge{
  display:inline-block;
  padding:4px 10px;
  border-radius:999px;
  font-size:12px;
  background:rgba(0,0,0,.06);
  font-weight:900;
}
.badge.off{ opacity:.7; background:rgba(0,0,0,.03); }

.topnav-link,
.topnav-dd-btn{
  display:inline-flex;
  align-items:center;
  height:38px;
  line-height:38px;
  padding-top:0;
  padding-bottom:0;
}

.topnav-dd{ padding-bottom:0; }
.topnav-dd::after{ height:6px; }

@media (max-width: 860px){
  .caret{ display:inline; opacity:.65; }

  .topnav-dd-btn, .topnav-link, .user-button{
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .topnav-dd-menu{
    position:fixed;
    left:10px;
    right:10px;
    top:calc(var(--topbar-h) + 8px);
    min-width:unset;
    width:auto;
    max-height:60vh;
    overflow:auto;
    z-index:20000;
  }

  .topnav-dd:hover .topnav-dd-menu{ display:none; }
  .topnav-dd.open .topnav-dd-menu{ display:block; }
}

.mobile-menu-btn{
  display:none;
  width:42px;
  height:42px;
  border:1px solid rgba(0,0,0,.08);
  border-radius:12px;
  background:rgba(255,255,255,.72);
  color:var(--text-primary);
  align-items:center;
  justify-content:center;
  font-size:22px;
  line-height:1;
  cursor:pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.mobile-menu-btn:active{ transform:scale(.98); }
.mobile-only{ display:none !important; }
.topbar-overlay{
  display:none;
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.18);
  z-index:9997;
}
.topbar-overlay.active{ display:block; }
html.menu-open, body.menu-open{ overflow:hidden; }

@media (max-width: 860px){
  :root{ --topbar-base-h:64px; }
  body{ padding-top: var(--topbar-h); }

  .topbar{
    height:var(--topbar-h);
    padding: calc(var(--safe-top) + 6px) 10px 6px;
    display:grid;
    grid-template-columns:auto 1fr auto;
    align-items:center;
    gap:8px;
  }

  .mobile-menu-btn,
  .mobile-only{ display:inline-flex !important; }

  .topbar-left{
    flex:0 0 auto;
    min-width:auto;
    gap:8px;
    margin-right:0;
  }

  .topbar-center{
    position:fixed;
    top:calc(var(--topbar-h) + 6px);
    left:10px;
    right:10px;
    width:auto;
    max-height:calc(100dvh - var(--topbar-h) - 20px);
    padding:10px;
    border:1px solid rgba(0,0,0,.08);
    border-radius:16px;
    background:rgba(255,255,255,.98);
    box-shadow:0 18px 48px rgba(0,0,0,.16);
    overflow:auto;
    z-index:9998;
    display:none;
    justify-content:flex-start;
  }
  .topbar-center.open{ display:flex; }

  .topbar-right{
    flex:0 0 auto;
    min-width:auto;
    justify-content:flex-end;
    gap:8px;
  }

  .topnav{
    width:100%;
    display:flex;
    flex-direction:column;
    gap:8px;
    overflow:visible;
    max-width:none;
  }

  .nav-full,
  .nav-short{ display:inline; }
  .nav-short{ display:none; }

  .topnav-link,
  .topnav-dd-btn{
    width:100%;
    min-width:0;
    justify-content:flex-start;
    text-align:left;
    padding:0 12px;
    height:44px;
    line-height:44px;
    border:1px solid rgba(0,0,0,.06);
    background:rgba(0,0,0,.02);
    border-radius:12px;
  }

  .topnav-dd{
    width:100%;
    padding-bottom:0;
  }
  .topnav-dd::after{ display:none; }

  .topnav-dd-menu{
    position:static;
    left:auto;
    right:auto;
    top:auto;
    margin-top:8px;
    width:100%;
    min-width:0;
    max-height:none;
    overflow:visible;
    border-radius:12px;
    box-shadow:none;
    background:rgba(0,0,0,.025);
    border:1px solid rgba(0,0,0,.06);
    padding:8px;
  }

  .topnav-dd:hover .topnav-dd-menu{ display:none; }
  .topnav-dd.open .topnav-dd-menu{ display:block; }

  .topnav-dd-menu a{
    min-height:42px;
    display:flex;
    align-items:center;
  }

  .topbar-logo{
    height:22px;
    opacity:.7;
  }

  .btn-icon,
  .user-button{
    width:42px;
    height:42px;
    padding:0;
    justify-content:center;
  }

  .user-dropdown{
    top:48px;
    right:0;
    width:220px;
    max-width:calc(100vw - 20px);
  }
}

@media (max-width: 520px){
  :root{ --topbar-base-h:60px; }

  .topbar{
    gap:6px;
    padding: calc(var(--safe-top) + 6px) 8px 6px;
  }

  .topbar-center{
    left:8px;
    right:8px;
    top:calc(var(--topbar-h) + 6px);
    max-height:calc(100dvh - var(--topbar-h) - 14px);
  }

  .topbar-logo{ height:20px; }
  .topnav-link,
  .topnav-dd-btn{ font-size:13px; }
}
